Skip to content

[PM-37487] Move collections client ownership to Admin Console - #1380

Open
JaredScar wants to merge 1 commit into
mainfrom
ac/pm-37487-move-collectionsClient-to-AC-ownership
Open

[PM-37487] Move collections client ownership to Admin Console#1380
JaredScar wants to merge 1 commit into
mainfrom
ac/pm-37487-move-collectionsClient-to-AC-ownership

Conversation

@JaredScar

Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-37487

📔 Objective

Move the collections client ownership over to Admin Console

…cryption

- Added `CollectionsClient` to handle encrypting and decrypting collections.
- Introduced `CollectionEncryptError` for managing encryption errors.
- Updated `Cargo.toml` to include `tokio` and `bitwarden-collections` as dependencies.
- Enhanced `bitwarden-pm` to expose `CollectionsClient` for top-level access.
- Updated relevant modules and tests to support new functionality.

This change improves the SDK's capability to manage collections securely and efficiently.
@JaredScar
JaredScar requested a review from a team as a code owner August 12, 2026 22:20
@JaredScar JaredScar added the ai-review Request a Claude code review label Aug 12, 2026
@JaredScar
JaredScar requested review from a team as code owners August 12, 2026 22:20
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR moves CollectionsClient (plus CollectionViewTree, CollectionViewNodeItem, and AncestorMap) from bitwarden-vault into bitwarden-collections, which CODEOWNERS already assigns to Admin Console, and surfaces a new top-level collections() accessor on the WASM, UniFFI, and bitwarden-pm clients while keeping vault().collections() as a staged migration path. The move is mechanically clean: all references were updated, no stale bitwarden_vault::collection_client paths remain, the wasm/uniffi feature wiring in bitwarden-pm is complete, and the bitwarden-core/tokio dev-dependency addition matches the pattern used by bitwarden-vault and bitwarden-importers. The one consumer-facing concern is the error type swap, which is not covered by the backwards-compatibility shim used for the accessor.

Code Review Details
  • ⚠️ : Collection encrypt/decrypt error identity changes on both TS and mobile bindings without a compat path
    • crates/bitwarden-collections/src/error.rs:12-23

Dependency Changes

Package Change Ecosystem
bitwarden-core New dev-dependency (internal, test-fixtures) Cargo
tokio New dev-dependency (rt) Cargo
bitwarden-collections New dependency of bitwarden-pm Cargo

All three are existing first-party or already-approved workspace dependencies, so no AppSec dependency review is required. Cargo.lock is updated consistently with the manifest changes.

Comment on lines +12 to +23
/// Generic error type for collection encryption errors.
///
/// This intentionally mirrors `bitwarden_vault::EncryptError` rather than depending on it, to
/// avoid creating a circular dependency between the `bitwarden-collections` and `bitwarden-vault`
/// crates.
#[allow(missing_docs)]
#[bitwarden_error(flat)]
#[derive(Debug, Error)]
pub enum CollectionEncryptError {
#[error(transparent)]
Crypto(#[from] bitwarden_crypto::CryptoError),
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ IMPORTANT: Finding 1: Swapping the collection client's error types silently changes the error identity that TS and mobile consumers match on.

Details and impact

CollectionsClient::{encrypt,encrypt_list} moved from bitwarden_vault::EncryptError to CollectionEncryptError, and {decrypt,decrypt_list} from bitwarden_vault::DecryptError to CollectionDecryptError. Because #[bitwarden_error(flat)] derives the binding surface from the enum name, this is consumer-visible on both bindings:

  • WASM/TS: the thrown error's name becomes "CollectionEncryptError" / "CollectionDecryptError", and the generated guard is now isCollectionEncryptError() / isCollectionDecryptError(). Existing isEncryptError(e) / isDecryptError(e) checks around collection calls now return false with no compile error.
  • UniFFI: bitwarden-uniffi/src/error.rs routes these through new BitwardenError::CollectionEncrypt / CollectionDecrypt variants, so catch (e: BitwardenException.Encrypt) / BitwardenException.Decrypt in Kotlin/Swift stops matching — also without a compile error.

The accessor move in this PR keeps vault().collections() around for a staged migration, but the error rename has no equivalent shim, so client-side error handling breaks the moment this version is consumed. Renaming to keep EncryptError via export_as is not viable (it would collide with bitwarden_vault::EncryptError in the same wasm module), so this likely needs a coordinated client change — worth calling out in the PR description / linked ticket so web and mobile pick it up.

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🔍 SDK Breaking Change Detection

SDK Version: ac/pm-37487-move-collectionsClient-to-AC-ownership (6b5d953)

⚠️ If breaking changes are detected, a corresponding pull request addressing them must be ready for merge in the affected client repository.

Client Status Details
typescript ❌ Breaking changes detected Compilation failed with new SDK version. A corresponding pull request addressing the breaking changes must be ready for merge in bitwarden/clients. - View Details
android ❌ Breaking changes detected Compilation failed with new SDK version. A corresponding pull request addressing the breaking changes must be ready for merge in bitwarden/android. - View Details

Breaking change detection uses the build of the SDK from this branch, including any incompatibities pre-existing on or merged into this branch. Check the workflow logs to confirm.
Results update as workflows complete.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.60976% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.27%. Comparing base (99ffb6e) to head (6b5d953).

Files with missing lines Patch % Lines
crates/bitwarden-pm/src/lib.rs 0.00% 3 Missing ⚠️
crates/bitwarden-uniffi/src/lib.rs 0.00% 3 Missing ⚠️
crates/bitwarden-wasm-internal/src/client.rs 0.00% 3 Missing ⚠️
crates/bitwarden-vault/src/vault_client.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1380      +/-   ##
==========================================
- Coverage   86.28%   86.27%   -0.02%     
==========================================
  Files         500      500              
  Lines       73417    73419       +2     
==========================================
- Hits        63349    63339      -10     
- Misses      10068    10080      +12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review breaking-change t:feat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants