Skip to content

fix(github): guard list-user-orgs against GitHub rate limits - #6404

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/github-list-user-orgs-rate-limit-w3
Aug 21, 2026
Merged

pedrofrxncx merged 1 commit into
mainfrom
fix/github-list-user-orgs-rate-limit-w3

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

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:

  1. That the failure is a rate limit (not a permission or connectivity issue)
  2. How long to wait before retrying
  3. Whether it's a primary (window exhausted) or secondary (burst/abuse) limit

This mirrors the hardening already in place for the GraphQL transport (graphql.ts:204-218).

How

  • Import the existing rate-limit utilities from @/observability/github-rate-limit
  • Check for rate limiting with isGithubRateLimited(res) before generic error throw
  • Record the rate-limit snapshot with recordGithubRateLimit() on every response
  • Count the rate-limit event with countGithubRateLimited() for observability
  • Surface retry-after guidance in the error message if GitHub provided it

Verification

  • bun run fmt: ✓
  • bunx tsc --noEmit in 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_ORGS REST 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.

  • Uses @/observability/github-rate-limit utilities: isGithubRateLimited, githubRetryAfterMs, recordGithubRateLimit, countGithubRateLimited.
  • Records rate-limit headers on every response and increments a counter when limited.
  • Throws an Error with retry-after seconds when limited; error type and tool API remain unchanged.

Written for commit 053fb74. Summary will update on new commits.

Review in cubic

@pedrofrxncx
pedrofrxncx merged commit e589850 into main Aug 21, 2026
33 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/github-list-user-orgs-rate-limit-w3 branch August 21, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

native: make isolated secure preview origins the Linux default

1 participant