Skip to content

Client.RateLimits shouldn't return RateLimitError #1899

@sa-spag

Description

@sa-spag

👋 Hello,

I noticed that Client.RateLimits can return a RateLimitError, as per:

go-github/github/github.go

Lines 648 to 652 in 75644ea

return &RateLimitError{
Rate: rate,
Response: resp,
Message: fmt.Sprintf("API rate limit of %v still exceeded until %v, not making remote request.", rate.Limit, rate.Reset.Time),
}

According to GitHub REST API documentation, rate limit status can be checked "at any time using the Rate Limit API", i.e. even when the remaining number of allowed requests is 0, and the GET /rate_limit endpoint never responds with a HTTP 403. I verified myself and I can confirm the documentation is accurate. Therefore, I think Client.RateLimits should never return RateLimitError errors and return the actual rate limit status, by performing a HTTP request.

I have 2 solutions in mind:

  • Client.checkRateLimitBeforeDo is aware of some allowlist of endpoints, including GET /rate_limits (and perhaps others I don't know yet about), for which it should always return nil;
  • a higher layer passes a boolean which indicates that the request should not be subject to the pre-request rate limit check, possibly exposed to the user so one could hit GitHub API regardless of the internal rate limit status.

Happy to discuss any solution before I (or someone else) patch(es) the issue. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions