Raise OAuthRefreshException on refresh failure and remove dead retry flow#109
Open
Copilot wants to merge 3 commits into
Open
Raise OAuthRefreshException on refresh failure and remove dead retry flow#109Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Copilot
AI
changed the title
Raise OAuthRefreshException and remove retry bookkeeping
Raise OAuthRefreshException on refresh failure and remove dead retry flow
Jun 1, 2026
Copilot created this pull request from a session on behalf of
glensc
June 1, 2026 11:11
View session
- Ensure TOKEN_UNDER_REFRESH is cleared on failures - Avoid leaving token auth stuck in refresh state Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: OpenCode (gpt-5.4) <noreply@openai.com>
- Replace inline refresh logging with OAuthRefreshException - Remove retry bookkeeping tied to the old failure path Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: OpenCode (gpt-5.4) <noreply@openai.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: OpenCode (gpt-5.4) <noreply@openai.com>
4370ed0 to
3b53f18
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR restores explicit failure semantics for OAuth token refresh by raising OAuthRefreshException when refresh requests fail, while simplifying the refresh flow by removing effectively-dead retry bookkeeping and ensuring refresh state is always reset.
Changes:
- Raise
OAuthRefreshExceptionon refresh failures (instead of logging and returning) and mark token validity as false. - Remove unused retry state/guards around refresh attempts.
- Ensure
TOKEN_UNDER_REFRESHis reset via afinallyblock; add a regression test for refresh-failure behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
trakt/api.py |
Raises OAuthRefreshException on refresh failure, removes dead retry logic, and guarantees refresh-state reset. |
tests/test_oauth.py |
Adds regression coverage for expired-token refresh failure raising OAuthRefreshException and updating state flags. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
glensc
approved these changes
Jun 2, 2026
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.
OAuth refresh failures regressed to silent behavior:
OAuthRefreshExceptionexisted but was never raised. Since refresh retries are effectively disabled (MAX_RETRIES = 1), the retry guard/error-logging branch added complexity without behavior value.Refresh failure semantics
TokenAuth.refresh_token()now raisesOAuthRefreshExceptiondirectly whenoauth/tokenrefresh calls fail (OAuthException/BadRequestException) instead of logging and returning.Retry path cleanup
MAX_RETRIESgate +refresh_attemptsstate/checks).api.py; exception payload parsing remains encapsulated inOAuthRefreshException.Refresh state safety
validate_token()now resetsTOKEN_UNDER_REFRESHin afinallyblock so failed refresh attempts cannot leave refresh state stuck.Regression coverage
OAuthRefreshExceptionwith expectederror/error_description, and confirms refresh state/token validity flags are updated correctly.