-
Notifications
You must be signed in to change notification settings - Fork 89
[PM-29709] Fix vault migration endpoint #2265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes the bulk cipher sharing functionality by ensuring cipher IDs are included in the request payload. The changes modify the request model structure to flatten the bulk share request format, making it compatible with the server's expected format for vault migration operations.
Changes:
- Updated
BulkShareCiphersRequestModelto useCipherRequestModeldirectly instead ofCipherCreateRequestModel, flattening the request structure - Added optional
idfield toCipherRequestModelwith a newincludeIdparameter for controlled inclusion - Refactored
CipherServiceto optimize dictionary creation timing
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| BitwardenShared/Core/Vault/Models/Request/CipherRequestModel.swift | Adds optional id field and includeId parameter to support bulk share operations |
| BitwardenShared/Core/Vault/Models/Request/BulkShareCiphersRequestModel.swift | Changes from CipherCreateRequestModel to CipherRequestModel with includeId: true to flatten request structure |
| BitwardenShared/Core/Vault/Services/API/Cipher/Requests/BulkShareCiphersRequestTests.swift | Updates test expectations to match new flattened request structure with cipher IDs |
| BitwardenShared/Core/Vault/Services/CipherService.swift | Moves dictionary creation after API call for logical flow optimization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2265 +/- ##
==========================================
+ Coverage 85.88% 85.98% +0.10%
==========================================
Files 1760 1768 +8
Lines 150938 152280 +1342
==========================================
+ Hits 129628 130942 +1314
- Misses 21310 21338 +28 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| // Create a dictionary for quick lookup of original ciphers by ID. | ||
| let ciphersById = Dictionary(uniqueKeysWithValues: ciphers.compactMap { cipher in | ||
| cipher.id.map { ($0, cipher) } | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Why is it necessary to move this after the server call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just moved it because if the server call fails we won't be making unnecessary computations.
| favorite: cipher.favorite, | ||
| fields: cipher.fields?.map(CipherFieldModel.init), | ||
| folderId: cipher.folderId, | ||
| id: includeId ? cipher.id : nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Which requests need the id to be nil when the cipher.id is not nil? I'm asking to see if we can just always set it as the cipher.id instead of checking the boolean.

🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-29709
📔 Objective
This pull request updates the bulk cipher sharing functionality to ensure cipher IDs are included in the request payload, which is necessary for proper identification during bulk operations. The changes primarily affect the request model and its initialization, as well as related tests and the service layer.
Bulk Share Model and Request Model Updates:
BulkShareCiphersRequestModelnow usesCipherRequestModelinstead ofCipherCreateRequestModelfor itsciphersproperty, allowing for inclusion of cipher IDs in bulk share requests.BulkShareCiphersRequestModelpassesincludeId: truetoCipherRequestModel, ensuring each cipher's ID is included in the request.CipherRequestModelstruct adds an optionalidfield, with documentation noting its use for bulk share operations.CipherRequestModelinitializer gains a newincludeIdparameter, defaulting tofalse, and sets theidfield accordingly. [1] [2]Testing and Service Layer Adjustments:
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes