Repository navigation
fix(github): guard list-user-orgs against GitHub rate limits - #6404
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #6282 (series)
What
GITHUB_LIST_USER_ORGS uses REST API directly but didn't guard against rate limiting like the shared GraphQL transport does. When GitHub's API is rate-limited (429 or 403 with retry-after), the tool threw a bare status code without extracting retry guidance or recording observability.
Why
Rate limits can happen mid-pagination on a long installations list. The caller deserves to know:
This mirrors the hardening already in place for the GraphQL transport (
graphql.ts:204-218).How
@/observability/github-rate-limitisGithubRateLimited(res)before generic error throwrecordGithubRateLimit()on every responsecountGithubRateLimited()for observabilityVerification
bun run fmt: ✓bunx tsc --noEmitin apps/api: ✓bun test ./apps/api/src/tools/github/list-user-orgs.test.ts: ✓ (3/3 pass)bunx oxlint apps/api/src/tools/github/list-user-orgs.ts: ✓ (0 errors)Diff: -4 / +22 (net +18 lines; one concern: rate-limit handling).
Summary by cubic
Guards the
GITHUB_LIST_USER_ORGSREST call against GitHub rate limits, aligning behavior with the GraphQL transport. Previously it threw a bare 429/403; now it detects rate limiting, classifies primary vs secondary, and surfaces retry-after guidance to improve resilience during pagination.@/observability/github-rate-limitutilities:isGithubRateLimited,githubRetryAfterMs,recordGithubRateLimit,countGithubRateLimited.Written for commit 053fb74. Summary will update on new commits.