fix: stabilize OAuth storage bridge last-write-wins under rapid token rotation [IDE-2104]#1352
Open
basti-snyk wants to merge 1 commit into
Open
fix: stabilize OAuth storage bridge last-write-wins under rapid token rotation [IDE-2104]#1352basti-snyk wants to merge 1 commit into
basti-snyk wants to merge 1 commit into
Conversation
… rotation [IDE-2104] Test_RegisterOAuthStorageBridge_SerializesRapidTokenRotations flaked on Windows CI: after three rapid token rotations the stored token was the first instead of the last. Root cause: when credentialUpdateWorker writes a token via conf.Set, the persisted OAuth key re-fires the storage-bridge callback, which calls QueueCredentialUpdate again and re-enqueues the same token behind newer ones. On Windows (15ms clock resolution) all rotation tokens share an expiry, so shouldUpdateToken lets the stale re-enqueued copy overwrite the final token. Fix: add an atomic.Pointer[string] guard (writingToken). The worker marks the token it is applying (cleared via defer so a panic cannot leave it armed) and QueueCredentialUpdate skips the re-entrant enqueue of that same token. Add a deterministic regression test using require.Never that is RED without the guard and GREEN with it across GOMAXPROCS 1/2/4. Produced by an automated flake-fix loop.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
PR Reviewer Guide 🔍
|
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.
Summary
Test_RegisterOAuthStorageBridge_SerializesRapidTokenRotations(Windows CI, IDE-2104), where after rapid token rotations the first token was stored instead of the last.credentialUpdateWorkerwrites a token viaconf.Set, the persisted OAuth key re-fires the storage-bridge callback, which callsQueueCredentialUpdateagain and re-enqueues the same token behind newer ones. On Windows (15 ms clock resolution) all rotation tokens share an expiry, soshouldUpdateTokenlets the stale re-enqueued copy overwrite the final token (last-write-wins violation).atomic.Pointer[string]guard (writingToken). The worker marks the token it is applying (cleared viadefer, so a panic cannot leave the guard armed) andQueueCredentialUpdateskips the re-entrant enqueue of that same token. A guard-drop is logged at Debug level (no token value).require.Never: RED without the guard, GREEN with it, acrossGOMAXPROCS1/2/4.Test plan
go test ./infrastructure/authentication/... -racegreenmake test(full unit suite) green at this commitThis fix was produced by an automated flake-fix loop.