Skip to content

Any Error or AuthFailed status set during a rate limit ends the wait, so requests resume while GitHub is still refusing them #391

Open

Description

@matt-edmondson

What's wrong

The rate-limit wait depends on the displayed status, not on the rate-limit state itself:

Several paths replace RateLimited with a different status while a rate limit is still in force:

  • Providers/GitHub.cs:798: a 403 that is not a rate limit becomes Error.
  • Providers/GitHub.cs:815: an HttpRequestException becomes Error.
  • Providers/GitHub.cs:839: an authentication failure becomes AuthFailed.
  • Providers/AzureDevOps.cs: project-not-found and VSS/HTTP errors become Error.

How it fails

GitHub, secondary rate limit

  1. The token is a fine-grained PAT without Actions read on a few repos. Those calls return 403 "Resource not accessible", which IsRateLimitResponse correctly treats as not a rate limit, so SetStatus(Error) runs on every poll of them.
  2. GitHub then imposes a secondary rate limit: 403 with Retry-After: 60. OnRateLimitExceeded sets RateLimited with a reset 60 s away.
  3. The next concurrent poll of one of the step-1 repos sets Status = Error.
  4. GetRateLimitWaitTime() (called before each request at GitHub.cs:749) now skips the reset and falls back to CalculateAdaptivePacing(). That uses the budget from the last successful response, which is still large during a secondary limit, so the delay comes out at well under a second.
  5. Requests go straight back out during the secondary limit, the status flips between Rate limited and Error, and GitHub's docs warn that continuing to send requests in this state can get the integration banned.

A single network blip during the window has the same effect. During a primary limit, if the last success left any budget, the wait drops to the 30 s pacing clamp instead of lasting until the reset.

Azure DevOps. A 429 calls OnRateLimitExceeded() with no reset time, which raises RateLimitSleep. If an owner names a missing project, Error is set again on every discovery pass. The next success's ClearStatus() then sees Error, not RateLimited, and never resets RateLimitSleep. The extra backoff stays on every later ADO request for the rest of the session.

Suggested fix

  • Keep the rate-limit state separate from the displayed status. In GetRateLimitWaitTime() and IsRateLimitedWithPendingReset(), gate on RateLimitResetTime > UtcNow alone.
  • Clear RateLimitResetTime only once it has passed or on a successful response. SetStatus(Error/AuthFailed, …) should not end the wait.
  • In ClearStatus(), reset RateLimitSleep to BaseRequestDelay on every success, whatever the previous status was.

Acceptance criteria

  • A test that rate-limits a provider with a future reset, calls SetStatus(ProviderStatus.Error, …), and asserts that GetRateLimitWaitTime() still waits until the reset.
  • A test that raises RateLimitSleep with a reset-less rate limit, sets Error, calls ClearStatus(), and asserts that RateLimitSleep == BaseRequestDelay.

Related, but a different root cause: #384 (the shared loop sleeps out the reset), #385 (Retry-After), #333 (budget never re-read).

Activity

  1. added
    bug
    on Oct 31, 2026
  2. matt-edmondson commented on Oct 31, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions