Skip to content

fix(auth): Log at warning level when a rate-limited token is expected to reset - #609

Merged
edgarrmondragon merged 5 commits into
mainfrom
feat/log-token-rate-limit-reset
Sep 1, 2026
Merged

fix(auth): Log at warning level when a rate-limited token is expected to reset#609
edgarrmondragon merged 5 commits into
mainfrom
feat/log-token-rate-limit-reset

Conversation

@edgarrmondragon

Copy link
Copy Markdown
Member

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 limit once 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 a WARNING when it determines a token has hit its rate limit, including:
    • a masked, non-secret token identifier (last 4 characters, e.g. ...abcd)
    • the used/limit counts
    • the expected reset time (ISO 8601, UTC)
  • The warning is deduped per reset window (only logs once until rate_limit_reset changes), so it won't spam on every has_calls_remaining() poll while waiting out the same window.
  • AppTokenManager (GitHub App installation tokens) inherits this automatically via its super().has_calls_remaining() call.

Test plan

  • tests/test_authenticator.py passes unchanged (44 passed)
  • ruff check / ruff format --check pass
  • Manually verified the log fires once with the expected fields and doesn't repeat on a second check within the same window:
    WARNING:tap_github.authenticator:Token ...abcd has hit its rate limit (4500/5000 used). Expected to reset at 2026-09-01T18:30:04.509913+00:00.
    

…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.
@edgarrmondragon
edgarrmondragon requested a review from a team as a code owner September 1, 2026 18:19
@edgarrmondragon edgarrmondragon changed the title feat(auth): log at warning level when a rate-limited token is expected to reset fix(auth): Log at warning level when a rate-limited token is expected to reset Sep 1, 2026
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>
@edgarrmondragon
edgarrmondragon added this pull request to the merge queue Sep 1, 2026
Merged via the queue into main with commit 644d861 Sep 1, 2026
9 checks passed
@edgarrmondragon
edgarrmondragon deleted the feat/log-token-rate-limit-reset branch September 1, 2026 22:12
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