Skip to content

Raise immediately on the token statuses RETRY_ERROR_DENY names - #194

Open
arpitjain099 wants to merge 1 commit into
CMSgov:mainfrom
arpitjain099:fix/token-retry-deny-list
Open

arpitjain099 wants to merge 1 commit into
CMSgov:mainfrom
arpitjain099:fix/token-retry-deny-list

Conversation

@arpitjain099

@arpitjain099 arpitjain099 commented Sep 22, 2026 •

Copy link
Copy Markdown

JIRA Ticket: none, outside contribution.

What Does This PR Do?

get_authorization_token_with_retry reads RETRY_ERROR_DENY backwards. The list names 400 and 429 as the statuses that should not be retried, but the condition is

if attempt == TOKEN_RETRY_TOTAL and status_code not in RETRY_ERROR_DENY:
    raise

so membership suppresses the raise rather than skipping the retries. Those two end up being the only statuses retried all the way to the last attempt, and once they get there nothing raises, the loop ends and the function returns None.

Changing and ... not in to or ... in makes them raise on the first failure and leaves every other status alone.

What Should Reviewers Watch For?

Whether raising straight away on a 429 is really what you want, or whether it deserves one backoff first. The list name says do not retry, so that is what I implemented, but it is your call.

Validation

Stubbed the token endpoint and kept time.sleep in place with the delays recorded. On main a persistent 400 or 429 calls the endpoint four times, sleeps for 30 seconds and returns None; a persistent 500 raises HTTPError after three retries. With the change 400 and 429 raise on the first failure with no sleep, and 500 behaves exactly as before.

The None is the part that matters. authorization_callback already catches the exception and reports ERR_TOKEN_EXCHANGE, so a token exchange failure currently slips past that handler, reaches the EOB call with no token and gets reported to the user as an EOB query error.

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
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.

1 participant