Conversation
|
New Issues (30)Checkmarx found the following issues in this Pull Request
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1029 +/- ##
==========================================
+ Coverage 6.79% 25.90% +19.11%
==========================================
Files 67 73 +6
Lines 2798 2957 +159
Branches 483 535 +52
==========================================
+ Hits 190 766 +576
+ Misses 2576 2074 -502
- Partials 32 117 +85 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
eliykat
left a comment
There was a problem hiding this comment.
Thank you for tackling this! I think spending some time getting proper tests on stateService and stateMigrationService will give us some peace of mind that we won't get an influx of tickets on release.
There was a problem hiding this comment.
I think we should consider removing the old migrations and just throwing if the stateVersion is not the minimum we expect. Account switching was released ~4 years ago, if you haven't opened DC since then you can just go download a fresh copy. Please check with Priya though.
Then you could just delete the legacy keys rather than moving them to their own file.
There was a problem hiding this comment.
We have the okay from Priya 👍
There was a problem hiding this comment.
Any ideas for testing this? e.g. could you configure the current DC version, then copy/paste your actual data.json into the code, then run a migration and assert the outcome?
I believe we have tests for it in the clients repo - the migration service has evolved a bit but should still give you the idea.
There was a problem hiding this comment.
Assuming the secure storage keys are changing, we're missing the following migrations:
- accessToken
- refreshToken
- apiKeyClientId
- apiKeyClientSecret
- twoFactorToken (if required)
| // @TODO Keep old key for now - will remove in future release | ||
| // await this.secureStorageService.remove(oldKey); |
There was a problem hiding this comment.
I don't disagree, but this migration will only run once. This would need to be done in a separately versioned migration.
| const normalized = new EnvironmentUrls(); | ||
|
|
||
| for (const [key, value] of Object.entries(urls)) { | ||
| if (!value || typeof value !== "string") { | ||
| continue; | ||
| } | ||
|
|
||
| let url = value.trim(); | ||
| url = url.replace(/\/+$/, ""); // Remove trailing slashes | ||
|
|
||
| if (!/^https?:\/\//i.test(url)) { | ||
| url = `https://${url}`; | ||
| } | ||
|
|
||
| normalized[key as keyof EnvironmentUrls] = url; |
There was a problem hiding this comment.
This was neater in its own private method. I think Claude may be over-optimizing.
|
@eliykat this is ready for another look when you have a moment, thanks. |
|
Code Review SummaryOverall Assessment: This PR implements a well-structured rewrite of the state service, moving from an account-based hierarchy to a simpler flat key-value structure. The changes are comprehensive and include proper test coverage. What was reviewed:
Strengths:
Items verified as non-issues:
Minor observations (not blocking):
The PR addresses the previous review feedback well and the implementation is solid. No blocking issues found. |









🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-31159
📔 Objective
This PR encompasses the totality of the state service re-write. This includes:
state.service.tsjslibjslibservices into the main directory structurejslibservice dependencies (e.g.crypto-service)jslibstate into DC app state (mostly electron related state).jslibcompatibility (stub files)jslibstate migration logic into DC's state migration servicejslibmodels📸 Screenshots