Keep Xaman callback state retry-safe - #25
Merged
Merged
Conversation
Validate first, exchange with WordPress, then atomically consume state before creating the local session.
Replace the obsolete consume-on-failure expectation with pending, retry-success and replay-rejection coverage.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Xaman/WordPress bridge callback flow to make login callbacks retry-safe by validating pending login state before contacting the bridge and deferring state consumption until after a successful bridge exchange, with corresponding regression test updates.
Changes:
- Reordered
POST /api/identity/callbackto validate pending state before the bridge exchange and to consume state only after a successful exchange. - Updated identity endpoint tests to assert pending status after transient (502) bridge failures, allow a successful retry, and reject subsequent replays.
- Refreshed callback documentation text to reflect the new ordering (though the docstring still contains redundant contract wording).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| backend/app/main.py | Reorders callback validation/exchange/consume to keep state retryable on transient bridge failures. |
| backend/tests/test_identity_endpoints.py | Updates/extends regression tests around transient failures, retry success, and replay rejection. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Preserve single-use concurrency and restore the state only after retryable 502-504 bridge failures.
Atomically reopen an unexpired consumed login state only for the retry path.
Require pending retry for 502 failures, failed handoff for permanent rejection, successful retry and blocked replay.
Removed redundant line from browser callback contract documentation.
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
Regression coverage
Tests require pending status after a transient failure, a successful retry, a rejected replay, a failed origin handoff after permanent rejection, and the existing one-success concurrency rule. No xfail or temporary test suppression is used.
Scope
Three backend files only: callback orchestration, the atomic retry-state helper, and existing identity endpoint tests. This clean branch supersedes the conflicted draft PR #1; merge only after every required check passes.