Fix GitHub Primary Rate Limit Errors Not Retried
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- github, typescript
- Lĩnh vực
- backend-api-design, distributed-systems
Hướng nghiên cứu
Start in packages/provider-github/src/http.ts, especially withRetry and assertResponseOk, then read the GitHubError definition and nearby tests. Add coverage for primary rate limit 403 responses, reset-header backoff, and Retry-After handling. Done means these errors retry using the provided timing headers where present, and the issue’s listed typecheck, test, and lint commands pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Codra's GitHub API client retries secondary rate limit errors (HTTP 403 with body "secondary rate limit") and HTTP 429/5xx errors, but does not retry primary rate limit errors. GitHub returns HTTP 403 (not 429) for primary rate limits, so these requests fail immediately and permanently, aborting in-progress reviews.
Affected File
packages/provider-github/src/http.ts - withRetry (lines 45-85):
const isSecondaryRateLimit =
error instanceof GitHubError &&
error.status === 403 &&
error.body?.toLowerCase().includes("secondary rate limit");
const isRetryable =
isSecondaryRateLimit ||
(error instanceof GitHubError && (error.status === 429 || error.status >= 500)) ||
error.name === "TimeoutError" ||
error.message.includes("timeout");
Why GitHub Uses 403 for Primary Rate Limits
GitHub's REST API returns HTTP 403 Forbidden with the error body "API rate limit exceeded for installation ID ..." and includes these response headers:
x-ratelimit-remaining: 0- confirms the quota is exhaustedx-ratelimit-reset: <epoch>- UTC epoch second when the quota resets
Since the check only recognizes "secondary rate limit" text, primary rate limit 403s fall through to the non-retryable path and immediately throw, causing the review to fail.
Proposed Fix
- Detect primary rate limit 403s:
const isPrimaryRateLimit =
error instanceof GitHubError &&
error.status === 403 &&
(error.body?.toLowerCase().includes("rate limit exceeded") ||
error.body?.toLowerCase().includes("api rate limit"));
- Capture
x-ratelimit-resetfrom response headers and use it to calculate precise sleep duration:
// In assertResponseOk - capture headers
throw new GitHubError(response.status, errText, path, `...`, response.headers);
// In withRetry - respect x-ratelimit-reset
const rateLimitReset = error.headers?.get("x-ratelimit-reset");
const delay = rateLimitReset
? Math.max(0, parseInt(rateLimitReset, 10) * 1000 - Date.now()) + 1000
: Math.pow(2, attempt) * 30000;
Done When
- HTTP 403 responses with primary rate limit body text are retried with appropriate backoff
-
x-ratelimit-resetheader is used to calculate wait time where present -
Retry-Afterheader on 429 responses is also respected -
GitHubErrorcarries response headers for use in retry logic - Tests cover primary rate limit 403 retry and
x-ratelimit-resetbackoff calculation -
npm run typecheck,npm test, andnpm run lintall pass
- Ngôn ngữ chính
- TypeScript
- Star
- 125
- Fork
- 23
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của devarshishimpi/codra
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
devarshishimpi/codra#178 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
devarshishimpi/codra#176 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
devarshishimpi/codra#186 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
devarshishimpi/codra#185 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
devarshishimpi/codra#184 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của devarshishimpi/codra
Issue tương tự
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 83/100
gofish-graphics/gofish-graphics#1384 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
adapter bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Olanetsoft/agent-lookout#353 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
vicharanashala/vibe#1542 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug chore P2 size:XS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
josephfung/curia#2666 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: batch
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
inabagumi/shinju-date#7294 ·
Maintainer thường phản hồi trong vòng 1 ngày