Repository navigation
Read GitHub rate-limit headers whatever their casing [patch] - #390
Merged
Merged
Conversation
Octokit keys response headers case-sensitively, as they arrived on the wire, and GitHub sends x-ratelimit-remaining and x-ratelimit-reset in lowercase. The exact-case X-RateLimit-* lookups missed them, so a spent primary budget fell through to the one-minute secondary backoff and was retried every minute until it reset. Look Retry-After and the X-RateLimit-* headers up through a helper that ignores case, as HTTP does. Fixes #389. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4T6sUBiRNom98NuYi
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4T6sUBiRNom98NuYi
…t always exits SonarCloud S1751 rated the Where loop, which returned on its first iteration, as a reliability bug. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4T6sUBiRNom98NuYi
|
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.



Fixes #389
What was wrong
Octokit keys
IResponse.Headerscase-sensitively, using each name as it arrived on the wire. GitHub sendsx-ratelimit-remainingandx-ratelimit-resetin lowercase, and proxies often re-case them asX-Ratelimit-*.ParseRateLimitResetTimeandIsRateLimitResponselooked up the exact spellingX-RateLimit-*, so they missed both. A spent primary budget then fell through to the one-minute secondary backoff and was retried every minute until the real reset.Change
GitHub.TryGetHeader. It tries the exact key first, then falls back to anOrdinalIgnoreCasescan.Retry-After,X-RateLimit-RemainingandX-RateLimit-Resetthrough it, in bothParseRateLimitResetTimeandIsRateLimitResponse.Tests
New cases in
GitHubRateLimitResetTests:X-Ratelimit-*headers waits for the reset (now+45 min), not now+1 min.retry-afteris honoured.remaining: 0, whose message doesn't mention a rate limit, counts as a rate limit.With the fix reverted, all 5 new cases fail. With it, the full
BuildMonitor.Testsuite passes (156/156).Generated by Claude Code