Skip to content

fix: Handle HTTP 429 status code for rate limiting#3951

Merged
gmlewis merged 1 commit intogoogle:masterfrom
abtris:fix-429-rate-limit-handling
Jan 30, 2026
Merged

fix: Handle HTTP 429 status code for rate limiting#3951
gmlewis merged 1 commit intogoogle:masterfrom
abtris:fix-429-rate-limit-handling

Conversation

@abtris
Copy link
Contributor

@abtris abtris commented Jan 30, 2026

GitHub API can return either 403 or 429 for rate limiting, but the library was only checking for 403. This caused 429 responses to be treated as generic ErrorResponse instead of RateLimitError or AbuseRateLimitError, breaking retry logic and rate limit handling.

Changes:

  • CheckResponse now detects 429 with X-RateLimit-Remaining: 0 as RateLimitError (primary rate limit)
  • CheckResponse now detects 429 with secondary rate limit documentation_url as AbuseRateLimitError

Reference: https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api

GitHub API can return either 403 or 429 for rate limiting, but the
library was only checking for 403. This caused 429 responses to be
treated as generic ErrorResponse instead of RateLimitError or
AbuseRateLimitError, breaking retry logic and rate limit handling.

Changes:
- CheckResponse now detects 429 with X-RateLimit-Remaining: 0 as
  RateLimitError (primary rate limit)
- CheckResponse now detects 429 with secondary rate limit
  documentation_url as AbuseRateLimitError

Reference: https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api
@abtris abtris changed the title Handle HTTP 429 status code for rate limiting fix: handle HTTP 429 status code for rate limiting Jan 30, 2026
@abtris abtris changed the title fix: handle HTTP 429 status code for rate limiting fix: Handle HTTP 429 status code for rate limiting Jan 30, 2026
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.45%. Comparing base (1c42933) to head (4ebe623).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3951   +/-   ##
=======================================
  Coverage   92.45%   92.45%           
=======================================
  Files         203      203           
  Lines       14980    14980           
=======================================
  Hits        13850    13850           
  Misses        927      927           
  Partials      203      203           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @abtris!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @alexandear - @zyfy29 - @Not-Dhananjay-Mishra

Copy link
Contributor

@Not-Dhananjay-Mishra Not-Dhananjay-Mishra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 30, 2026

Thank you, @Not-Dhananjay-Mishra!
Merging.

@gmlewis gmlewis merged commit 72c952a into google:master Jan 30, 2026
8 checks passed
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.

3 participants