fix: resolve AuthenticationController 401 errors from token caching bugs#8144
Merged
mathieuartu merged 16 commits intomainfrom Mar 10, 2026
Merged
fix: resolve AuthenticationController 401 errors from token caching bugs#8144mathieuartu merged 16 commits intomainfrom
AuthenticationController 401 errors from token caching bugs#8144mathieuartu merged 16 commits intomainfrom
Conversation
b4e071c to
75ae8bd
Compare
packages/profile-sync-controller/src/controllers/authentication/AuthenticationController.ts
Show resolved
Hide resolved
75ae8bd to
8e4f77e
Compare
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
AuthenticationController race condition with undefined entropySourceIdentropySourceId to primary SRP to fix token caching and dedup
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
packages/profile-sync-controller/src/sdk/authentication-jwt-bearer/flow-srp.ts
Show resolved
Hide resolved
entropySourceId to primary SRP to fix token caching and dedupAuthenticationController 401 errors from token caching bugs
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
mathieuartu
commented
Mar 9, 2026
packages/profile-sync-controller/src/sdk/authentication-jwt-bearer/flow-srp.ts
Show resolved
Hide resolved
mathieuartu
commented
Mar 9, 2026
packages/profile-sync-controller/src/controllers/authentication/mocks/mockResponses.ts
Show resolved
Hide resolved
2ce348f to
d7e0234
Compare
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
ccharly
reviewed
Mar 10, 2026
packages/profile-sync-controller/src/controllers/authentication/AuthenticationController.ts
Show resolved
Hide resolved
packages/profile-sync-controller/src/sdk/utils/validate-login-response.ts
Outdated
Show resolved
Hide resolved
packages/profile-sync-controller/src/controllers/authentication/AuthenticationController.ts
Outdated
Show resolved
Hide resolved
ccharly
reviewed
Mar 10, 2026
mikesposito
approved these changes
Mar 10, 2026
Member
mikesposito
left a comment
There was a problem hiding this comment.
ProfileMetricsController changes look good
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Needed changes are in the test-drive PRs below.
Extension test-drive PR: MetaMask/metamask-extension#40711
References
Related to https://consensyssoftware.atlassian.net/browse/MUL-1549
Checklist
Note
High Risk
Touches authentication session validation and token retrieval behavior (including breaking test/mock contract), which can affect login/coalescing and any consumers relying on cached tokens.
Overview
Fixes profile auth/token caching edge-cases that could lead to stale bearer tokens (401s).
profile-sync-controllernow validates cached login sessions by decoding the JWTexpclaim (rejecting expired/malformed/non-JWT tokens) and resolvesundefinedentropySourceIdto the primary SRP ID (cached across calls and cleared on sign-out), eliminating duplicate logins caused byundefinedvs explicit primary IDs;getUserProfileLineageis updated to accept an optionalentropySourceIdend-to-end.profile-metrics-controllermovesAuthenticationController:getBearerTokenacquisition inside the retry execution so each retry fetches a fresh token. E2E/test mocks are updated to wrap mock identifiers in JWT-shaped tokens and providegetE2EIdentifierFromJwtto extract the original identifier.Written by Cursor Bugbot for commit 884180c. This will update automatically on new commits. Configure here.