You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(auth): propagate transient refresh failures during sign out - #2071
When an expired session must be refreshed before sign-out, a JSON HTTP 429 or 500 is classified as AuthApiError. The sign-out handler treated it as token rejection and silently cleared the session even though no logout request was sent. This left callers unable to retry global revocation.
Preserve the session and raise HTTP 429/5xx refresh errors for global/others scopes. Local scope still clears the local session and emits SIGNED_OUT, then raises the refresh error. Definite rejection handling and public error types are unchanged. This is a narrow v2 follow-up to #1823 / #1824; v3's policy is described in #2021.
Validation: four added async cases fail before the fix; after it, 76 selected sign-out cases pass across async and generated sync clients. Added cases cover JSON 429/500 across global/local/others. Ruff lint/format and mypy on both changed source files pass. Sync files were regenerated using the repository's unasync script and formatted. No live Auth integration suite was run.
Summary by CodeRabbit
Bug Fixes
Sign-out now handles rate-limit and server errors consistently: local sign-out clears the session, while other scopes retain it. The error is still reported in every case.
Tests
Added coverage for rate-limit and server errors across sign-out scopes.
No actionable comments were generated in the recent review.
Walkthrough
Sign-out now re-raises refresh API errors with status 429 or 500+. For local scope, both clients clear the session and emit SIGNED_OUT before raising. For global and others scopes, they preserve the session. Tests cover both statuses across all scopes.
Both clients separately handle AuthApiError statuses 429 and 500+. They re-raise the error for every scope; local scope clears the session and emits SIGNED_OUT. Tests cover both statuses for global, local, and others scopes.
supabase/supabase-py#2021: Implements related refresh-failure handling for 429 and 5xx responses in the v3 design.
Suggested reviewers:irisfield, o-santi
Merge Risk: Minimal · up to 4463f
Sign-out now surfaces transient refresh failures such as rate limiting and server errors instead of treating them as token rejection. Sessions are preserved for global and others scopes, and local scope clears the session. No remaining merge-blocking risk was found.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Linked Issues check
Issue #2070 requires, for JSON HTTP 429 and 500 refresh errors in sign_out: (1) global scope raises, keeps the session, and emits no SIGNED_OUT; (2) local scope clears the local session, emits SIGNED_…
Provide readable blobs for the changed files at the reviewed head: src/auth/src/supabase_auth/_async/gotrue_client.py, src/auth/src/supabase_auth/_sync/gotrue_client.py, src/auth/tests/_async/test_gotrue.py, and src/auth/tests/_sync/test_go…
Passed checks: 3 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the fix (propagating transient refresh failures during sign out) and the scope (auth). The PR changes sign_out in the async and sync GoTrue clients so HTTP 429 and 5xx refresh errors a…
Out of Scope Changes check
The raw summary lists only small changes in the sign-out path of the async and sync GoTrue clients (+8/-1 each) and matching test additions (+6/-0 in each test file). It reports no changes to public o…
Full details: Title check
Explanation
The title names the fix (propagating transient refresh failures during sign out) and the scope (auth). The PR changes sign_out in the async and sync GoTrue clients so HTTP 429 and 5xx refresh errors are re-raised, with matching test coverage. The title matches the main change, so the check passes.
Full details: Out of Scope Changes check
Explanation
The raw summary lists only small changes in the sign-out path of the async and sync GoTrue clients (+8/-1 each) and matching test additions (+6/-0 in each test file). It reports no changes to public or exported declarations and no changes to error types or to the definite-rejection branch. Each change maps to issue #2070. The sync files are described as regenerated from the async source, which matches the stated unasync workflow. Changes outside these four files are not described in the PR evidence. The diff itself could not be read, so this verdict relies on the summary.
Full details: Linked Issues check
Explanation
Issue #2070 requires, for JSON HTTP 429 and 500 refresh errors in sign_out: (1) global scope raises, keeps the session, and emits no SIGNED_OUT; (2) local scope clears the local session, emits SIGNED_OUT, and raises; (3) others scope raises and keeps the session; (4) definite token-rejection handling is unchanged. The raw summary of the PR states that AsyncGoTrueClient.sign_out and SyncGoTrueClient.sign_out now follow this behavior, and that tests cover 429 and 500 across global, local, and others. The PR description reports four added async cases, while the issue and the summary describe six cases. The whole-PR diff for the source and test files could not be read: the changed blobs are missing from the checkout. The file read of _async/gotrue_client.py was truncated before sign_out, so the except-branch logic was not verified. Requirements (1) to (4) therefore rest on the AI-generated summary and the PR description, not on source evidence.
Resolution
Provide readable blobs for the changed files at the reviewed head: src/auth/src/supabase_auth/_async/gotrue_client.py, src/auth/src/supabase_auth/_sync/gotrue_client.py, src/auth/tests/_async/test_gotrue.py, and src/auth/tests/_sync/test_gotrue.py. Then confirm in the sign_out except-block that status 429 and status 500 and above route to the scope-dependent path, that the local branch clears the session and emits SIGNED_OUT before re-raising, and that the test set covers 429 and 500 for all three scopes.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
We only accept critical bug or security fixes for v2, this is not critical: it's an edge case that needs a coincidental rate limit or outage at sign-out.
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
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.
Fixes #2070. Targets the stable v2 branch.
When an expired session must be refreshed before sign-out, a JSON HTTP 429 or 500 is classified as AuthApiError. The sign-out handler treated it as token rejection and silently cleared the session even though no logout request was sent. This left callers unable to retry global revocation.
Preserve the session and raise HTTP 429/5xx refresh errors for global/others scopes. Local scope still clears the local session and emits SIGNED_OUT, then raises the refresh error. Definite rejection handling and public error types are unchanged. This is a narrow v2 follow-up to #1823 / #1824; v3's policy is described in #2021.
Validation: four added async cases fail before the fix; after it, 76 selected sign-out cases pass across async and generated sync clients. Added cases cover JSON 429/500 across global/local/others. Ruff lint/format and mypy on both changed source files pass. Sync files were regenerated using the repository's unasync script and formatted. No live Auth integration suite was run.
Summary by CodeRabbit