Kotlin local date#1154
Conversation
Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR converts The implementation follows the patterns established by the sibling Code Review Details
|
| date_of_birth: self | ||
| .date_of_birth | ||
| .decrypt(ctx, key) | ||
| .ok() | ||
| .flatten() | ||
| .and_then(|s: String| s.parse().ok()), |
There was a problem hiding this comment.
❓ QUESTION: Silent data loss when the decrypted date string is not a valid ISO 8601 date.
Details
.and_then(|s: String| s.parse().ok()) discards the value when parsing fails, so any existing encrypted data containing a non-NaiveDate-parseable string (e.g. "06/15/1985", "June 15, 1990", an empty string, or any locale-specific format a prior client may have stored before this type-safety pass) decrypts successfully but appears as None in the PassportView. The encrypted string is still on the server, but the user-facing field silently empties.
This same pattern repeats for issue_date (109-114) and expiration_date (115-120), and again in DriversLicense::decrypt and the blob From<&PassportDataV1> / From<&DriversLicenseDataV1> conversions.
Given these cipher types are recent (commit e504da35) and clients have not yet shipped UIs that write to them, real-world impact is likely small — but two questions are worth confirming before merge:
- Is silent coercion to
Noneon parse failure the desired behavior, or shoulddecryptsurface aCryptoError(or at minimum emit atracing::warn!) so non-ISO data is observable rather than disappearing? - The existing
test_recorded_*_test_vectortests assert backwards-compat for the encrypted-string format, but they only cover values that already happen to be ISO. Worth a unit test asserting the chosen behavior for a non-parseable decrypted string so the contract is locked in.
|
🔍 SDK Breaking Change DetectionSDK Version:
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. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1154 +/- ##
==========================================
+ Coverage 84.12% 84.14% +0.02%
==========================================
Files 446 446
Lines 58817 58912 +95
==========================================
+ Hits 49478 49572 +94
- Misses 9339 9340 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
coroiu
left a comment
There was a problem hiding this comment.
Whether NaiveData is the correct usage here or not will have to be up to Vault (my understanding is that timezone data will be lost), but the bigger hurdle for this PR is WASM support. You'll have to confirm what type of object NaiveDate is translated into on the TypeScript side and then add a custom typescript section for it, similar to how DateTime looks (search for it in the code to find where to put it:
/**
* RFC3339 compliant date-time string.
* @typeParam T - Not used in JavaScript.
*/
export type DateTime<T = unknown> = string;
Most of the changes seem to be within Vaults domain so make sure to reach out to them for help and guidance!
nick-livefront
left a comment
There was a problem hiding this comment.
Whether NaiveData is the correct usage here or not will have to be up to Vault (my understanding is that timezone data will be lost)
These specific dates do not have timezone data, they're only YYYY-MM-DD dates.
I do agree with the custom types approach that @coroiu suggested as the NaiveDate gets converted to a string on the TS side. The other option I considered was adding #[cfg_attr(feature = "wasm", tsify(type = "string"))] to each property but that would be tedious to maintain.
I'll send this to our internal channel to see if there are any other opinions but I think you could continue with the custom type.
afce2d3 to
942c74a
Compare
942c74a to
8605774
Compare



🎟️ Tracking
N/A
📔 Objective
This is my first SDK PR and Claude helped me manage a lot of the heavy lifting, please let me know if I am properly honoring the best practices.
This PR updates the date values in the SDK for some of the new cipher types to utilize the Rust
NaiveDateand translate it to a JavaLocalDate.🚨 Breaking Changes
This will create a breaking change for the Kotlin output of the SDK where previously certain date Strings will now be converted to the type-safe
LocalDateclass. This is required to enforce a consistent date format that can be parsed an utilized properly across the platforms.