Skip to content

Keep Xaman callback state retry-safe - #25

Merged
xrpbanks merged 7 commits into
mainfrom
fix/retry-safe-xaman-callback-v2
Aug 29, 2026
Merged

Keep Xaman callback state retry-safe#25
xrpbanks merged 7 commits into
mainfrom
fix/retry-safe-xaman-callback-v2

Conversation

@xrpbanks

@xrpbanks xrpbanks commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • atomically reserve the pending state before contacting the WordPress/Xaman bridge
  • allow only one concurrent callback to attempt the external exchange
  • restore an unexpired state only after retryable 502-504 bridge failures
  • keep permanent rejections consumed and mark the origin handoff failed

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.

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.
Copilot AI lite review requested due to automatic review settings August 29, 2026 23:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/callback to 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.

Comment thread backend/app/main.py Outdated
Comment thread backend/app/main.py Outdated
Comment thread backend/app/main.py
Comment thread backend/tests/test_identity_endpoints.py
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.
@xrpbanks
xrpbanks merged commit 62ed99a into main Aug 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants