question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getRateLimit() ignores header rate limit

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bitwisemancommented, May 13, 2020

@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.

0reactions
bitwisemancommented, May 18, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

getRateLimit() ignores header rate limit · Issue #802 - GitHub
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...
Read more >
API host's rate-limit header not read properly - Stack Overflow
Here is my code (not the entire code, but I think this is the only really relevant part): const timer = ms =>...
Read more >
RateLimit Header Fields for HTTP - IETF
This document defines the RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset header fields for HTTP, thus allowing servers to publish ...
Read more >
Issue 2551036: Support rate limiting in REST (and xmlrpc ...
I have a POC implementation to rate limit the rest interface using the GCRA implementation used for issue2550949. It returns the standard headers:...
Read more >
RateLimitChecker (GitHub API for Java 1.302 API)
getRateLimit() . The "requests per interval" is referred to as the "rate limit". GitHub prefers that clients stop before exceeding their rate limit...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found