Repository navigation
fix(server): return the saved state explicitly from successor creation - #2649
Merged
Merged
Conversation
createPlacedSuccessorLocked now returns whether it saved the successor, and Clear and Fork close a pre-opened identity broker session from that flag instead of from a non-empty session ID. Clear also checks the source's owner after the reload under the mutation lease, before it cancels the source. Closes #2612 Co-authored-by: Mecatl <[email protected]>
ChrisJBurns
marked this pull request as ready for review
November 2, 2026 19:55
jhrozek
approved these changes
Nov 2, 2026
Merged
2 tasks
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.
Closes #2612
Summary
Before this change, Clear and Fork decided whether to close a pre-opened identity broker session from a convention:
createPlacedSuccessorLockedreturned a non-empty session ID exactly when it had saved the successor. Nothing enforced that, so a mistake could leak a broker session holding a converted refresh token, or close the wrong one.createPlacedSuccessorLockednow returns(id, saved, err).savedis the single source of truth: the function's own deferred close and Clear's deferred close both read it.bearer_rejected. The identity broker emits it too; the comments now say so.Testing
TestCreatePlacedSuccessorReportsSavedExactly. It checks thatsavedis true exactly when the successor can be loaded from the store, on success, on a store failure before the save, and on a reference-commit failure after the save. Forcing a wrong flag on either side makes it fail.TestSuccessorSavedThenFailedKeepsItsBrokerSession(Clear and Fork). When the successor is saved and a later commit fails, the call returns the ID with an internal error, and the successor's broker session stays open.TestClearRefusesASourceWhoseOwnerChangedBeforeCancelling. It fails before the change because the source ended up cancelled.go test -race ./internal/adapter/server/...passes exceptTestACPUsesHostGovernanceRootAndClosesRejectedBindingandTestLoadACPSessionOwnsExactBindingUntilOverrideLifecycleEnds, which fail the same way on a cleanmain.task lintpasses for the root module. It stops at an existing gosec finding inenvironment/microvm/launch_ownership_darwin.go:754, which this PR does not touch.task test:raceand the offline demo.savedthe same way as the reference-commit path, which is tested.API compatibility
No wire change. The change is an internal return value and the order of an internal check, and API callers get the same session IDs and error codes as before. The one new refusal, a source whose owner changed between Clear's two loads, uses the existing internal error, and no server path reassigns a session's owner.