Details
-
Type:
Bug
-
Status: Closed (View Workflow)
-
Priority:
Major
-
Resolution: Fixed
-
Component/s: github-api-plugin, github-branch-source-plugin
-
Labels:None
-
Environment:github-branch-source v2.6.0
-
Similar Issues:
Description
The changes in JENKINS-59039 have broken rate limiting on our GitHub Enterprise instance.
This GHE instance does not return rate limit information via the /rate_limit endpoint
{ "message": "Rate limiting is not enabled.", "documentation_url": "https://developer.github.com/enterprise/2.19/v3/rate_limit/#get-your-current-rate-limit-status" }
but does return X-RateLimit headers on every request:
< X-RateLimit-Limit: 5000 < X-RateLimit-Reset: 1588603124 < X-RateLimit-Remaining: 4999
Before JENKINS-59039, it looks like the code called org.kohsuke.github.GitHub#rateLimit, which will return header-based rate limit info if it exists. Now the code calls org.kohsuke.github.GitHub#getRateLimit, which exclusively uses the /rate_limit endpoint.
The end result is that the plugin does not throttle itself during organization/repository scanning and for repositories with large numbers of branches, the scan ends up failing when the rate limit is exceeded.
Unfortunately I don't think modifying the response of the /rate_limit endpoint is an option. Any chance the plugin can be modified to call org.kohsuke.github.GitHub#rateLimit like it used to?
The problem is that org.kohsuke.github.GitHub#rateLimit may be stale and then throttling still doesn't work.
The correct solution is to update getRateLimit() to handle this case, specifically to use the header rate limit information if it is present even on a 404 of the /ratelimit endpoint. Please file an issue with the github-api project - https://github.com/github-api/github-api