Implement comprehensive rate limit handling for GitHub API requests with GHES compatibility#13
Implement comprehensive rate limit handling for GitHub API requests with GHES compatibility#13
Conversation
Co-authored-by: CallMeGreg <110078080+CallMeGreg@users.noreply.github.com>
|
@copilot when checking if the error was related to a rate limit, simplify the logic to only check if both of these conditions are met:
If they are both met, sleep until the time specified by the |
Co-authored-by: CallMeGreg <110078080+CallMeGreg@users.noreply.github.com>
I've simplified the rate limit handling logic as requested. The new implementation only checks for two specific conditions:
When both conditions are met, it parses the Key changes in commit 352ba15:
The approach is now much more reliable and maintainable. |
|
@copilot Does the logic gracefully handle when |
Co-authored-by: CallMeGreg <110078080+CallMeGreg@users.noreply.github.com>
Yes, the logic now gracefully handles when Enhanced Logic:
This ensures the tool works reliably with both GitHub.com (with headers) and GHES environments (without rate limit headers configured). Commit: 7857cf6 |
|
@copilot is the |
|
@copilot what happens when the |
Co-authored-by: CallMeGreg <110078080+CallMeGreg@users.noreply.github.com>
You're absolutely right. I've fixed the logic - if the Fixed in commit 281851d. |
When the |
This PR adds robust rate limit handling throughout the project to gracefully handle GitHub API rate limits, preventing the tool from failing when rate limits are exceeded and ensuring reliable operation at scale across both GitHub.com and GitHub Enterprise Server (GHES) environments.
Problem
The current implementation makes direct calls to
gh.Exec()without any rate limit handling. When GitHub API rate limits are exceeded (returning 403 or 429 responses), the tool fails immediately, making it unreliable for large-scale operations across multiple organizations.Solution
Added a comprehensive rate limit handling system that:
1. Rate Limit Detection
x-ratelimit-remainingheader is0to confirm rate limiting when header is presentx-ratelimit-remainingheader for GHES environments without rate limit configuration - if header is missing, it's NOT a rate limit error2. Automatic Retry Logic
x-ratelimit-resetheader (Unix timestamp) for precise reset times3. User-Friendly Experience
4. Comprehensive Coverage
ghExecWithRateLimit()wrapper functiongh.Exec()calls throughout the codebase5. Enterprise Server Support
x-ratelimit-remainingheader exists and equals "0"Technical Implementation
The implementation uses a precise and reliable approach:
x-ratelimit-remaining: 0header when presentx-ratelimit-resetheader for precise Unix timestampTesting
The solution ensures the tool can handle high-volume operations across enterprise organizations without failing due to rate limits, making it production-ready for large-scale deployments using reliable header-based detection that works correctly with both GitHub.com and GHES environments.
Fixes #9.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.