getRateLimit() ignores header rate limit
See original GitHub issueDescribe the bug
I use a GitHub Enterprise instance that does not support the /rate_limit
endpoint (it returns a 404 error) but it does return X-RateLimit
headers.
org.kohsuke.github.GitHubClient#getRateLimit
only checks the /rate_limit
endpoint, and thus returns an “unknown” rate limit in this case, even though there is a configured rate limit, causing the client to potentially exceed that limit.
To add insult to injury, on our GHE instance calls to /rate_limit
count against our rate limit, so we exceed the limit that much faster. 😄 I believe there are plans to address this, but I don’t know the timeframe.
Expected behavior
org.kohsuke.github.GitHubClient#getRateLimit
should return valid rate limit information if the server supports either the /rate-limit
endpoint or the X-RateLimit
headers.
Ideally the client would cache the knowledge of whether the /rate_limit
endpoint is available, and fall back to exclusively using the headers in this case.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (3 by maintainers)
Top GitHub Comments
@timja This is an easy fix. Basically, if the headers contain a rate limit we should return that even if the
/ratelimit
returns a 404. I think we can do this without breaking anything.Custom rate limiting shouldn’t be needed.
Ah, not so bad. We actually protect against the search rate limit problem:
https://github.com/hub4j/github-api/blob/85c44b352958bf6d81b74ab8b21920f1d313a287/src/main/java/org/kohsuke/github/GitHubClient.java#L501-L504