fix(auth): Log at warning level when a rate-limited token is expected to reset - #609
Merged
Merged
Conversation
…d to reset When rotating tokens after hitting a rate limit, there was no signal in the logs for when a given token would become usable again, making it hard to tell from CI logs whether/when a run should be expected to recover on its own. TokenManager.has_calls_remaining() now logs a warning (once per reset window, to avoid repeating on every check) with a masked token identifier, usage counts, and the expected reset time when a token is found to be rate-limited. AppTokenManager inherits this via its super().has_calls_remaining() call.
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
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
While digging into the CI rate-limit failures on #607, there was no signal in the logs for when a given token would become usable again once it hit its rate limit — just repeated
RuntimeError: All GitHub tokens have hit their rate limitonce every token in the pool was exhausted, with no indication of how long to wait or which token(s) were the blocker.Changes
TokenManager.has_calls_remaining()now logs aWARNINGwhen it determines a token has hit its rate limit, including:...abcd)rate_limit_resetchanges), so it won't spam on everyhas_calls_remaining()poll while waiting out the same window.AppTokenManager(GitHub App installation tokens) inherits this automatically via itssuper().has_calls_remaining()call.Test plan
tests/test_authenticator.pypasses unchanged (44 passed)ruff check/ruff format --checkpass