Commit e785797
OAuth: don't delete repositories when rate limited by GitHub (#13240)
A rate-limited GitHub API request [fails with a
403](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api),
and `update_or_create_repositories()` treats any 403 as if we lost
access to the repository — deleting the `RemoteRepository` and silently
disconnecting its projects. Large installations are currently hitting
the rate limit during webhook-triggered syncs, so this is actively
waiting to happen.
A rate limit now aborts the operation without deleting anything, and
without making further doomed requests. The task still fails visibly —
no retries. PyGithub raises `RateLimitExceededException` (a
`GithubException` subclass) for both [primary and secondary rate
limits](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits),
so catching it before the generic 403/404 handling covers both.
Reducing the API usage that triggers the rate limits is handled
separately in #13241, #13242, and #13243. Likely related to #13101,
since build statuses and PR comments share the same per-installation
budget.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01LVjkPjH3EDEQmtywJvDVau
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8acd566 commit e785797
2 files changed
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
247 | 248 | | |
248 | 249 | | |
249 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
250 | 260 | | |
251 | 261 | | |
252 | 262 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
596 | 598 | | |
597 | 599 | | |
598 | 600 | | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
599 | 628 | | |
600 | 629 | | |
601 | 630 | | |
| |||
0 commit comments