fix: stop on rate limits, cut GitHub API volume, add CI smoke mode - #152
Merged
Conversation
Add RateLimitError plus raise_for_github_errors() so rate-limit-shaped 403s (remaining=0, Retry-After, or secondary-rate-limit body marker) and post-retry 429s abort the run with one diagnosable log line instead of being swallowed by per-repo `except requests.RequestException` handlers. Cut issue listing volume with per_page=100 and a dlt incremental `since=` cursor, replace the hand-rolled Link-header loop with RESTClient.paginate(), and add --max-repos for a fast PR smoke run.
dlt wraps exceptions raised inside a resource generator as PipelineStepFailed -> ResourceExtractionError -> RateLimitError, so main()'s 'except RateLimitError' never fired and the run fell through to the generic handler, marking the resource failed and continuing into the same limit. Walk the cause chain with find_rate_limit_error() instead.
edmundmiller
force-pushed
the
github-pipeline-hardening
branch
from
August 19, 2026 17:42
d37abbf to
9efb7f7
Compare
edmundmiller
marked this pull request as ready for review
August 19, 2026 17:42
This was referenced Aug 19, 2026
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.
Stacked on #151 (base
fix/rate-limit-preflight; retarget tomainonce #151 merges).Diagnosis
Run 32260435568 (draft PR #151) showed the real failure mode. The core quota was healthy — 5000 → 4635 (365 calls consumed) through
commit_stats+traffic_stats, with core reset at 14:51:02. But at 14:21:29 a 403 arrived carrying reset 14:28:48 — a different bucket, i.e. GitHub's secondary rate limit, triggered by the bursty sequential comment loop inissue_stats(thetoolsrepo).This was not primary-quota exhaustion, and it was not caused by
commit_statsvolume.The damage came from error handling: every per-repo/per-issue handler catches
requests.RequestExceptionandcontinues, so the run fired ~2,500 doomed requests at ~20 req/s for 90 s and still went green.Changes
RateLimitError+ diagnosable logging (_github.py): newraise_for_github_errors()treats a 403 as a rate limit when any of remaining0, aRetry-Afterheader, or asecondary rate limitbody marker is present, logs one line with all four header values (resource,remaining,reset,retry_after), and raisesRateLimitError. Post-retry 429s raise it too. Non-rate-limit 403s still fall through toraise_for_status().except RateLimitError: raiseadded above each existingexcept requests.RequestExceptioningithub_pipeline.py(traffic_stats,contributor_stats,issue_statsissues + comments,pipelineswebsite JSON + releases,commit_stats) andcitations_pipeline.py.main()'s resource loop now catchesRateLimitErrorexplicitly and breaks, instead of string-matching"rate limit"in the message.issue_statsusesper_page=100(was defaulting to 30) and adlt.sources.incremental("updated_at")cursor feedingsince=.RESTClient.paginate()replaces the manual Link-header loop, reusing dlt's retry-enabled session. Signature unchanged; the non-list passthrough contract (e.g.stats/contributors202) is preserved.--max-repos Nlimits all resources to the first N org repos; the PR (non-runitor) branch ofrun_pipelines.ymlpasses--max-repos 25for thegithubpipeline. Scheduled/push production runs are unchanged.pipeline/AGENTS.md: documents thatGET /rate_limitis not a reliable preflight, that secondary limits exist with their own reset independent of the core bucket, and thatRateLimitErrormust never be swallowed.Verification
uvx ruff check src/— clean.0; andRetry-Afterwith remaining4999) and a 429 all raiseRateLimitError; a plain 403 does not.--max-repos 3: all 7 resources green, 93,676 rows.issue_stats4,395 → 0 rows and 16 min → 18 s, confirming the incrementalsince=cursor took effect.Update: dlt exception wrapping
The first CI run went red even though the stop logic worked: dlt wraps exceptions raised inside a resource generator as
PipelineStepFailed->ResourceExtractionError->RateLimitError, somain()'sexcept RateLimitErrornever fired and the run fell through to the generic handler (marking the resource failed and continuing into the same limit). Fixed in 7999f44 withfind_rate_limit_error(), which walks the cause chain instead of string-matching the message. Documented inpipeline/AGENTS.md.That red run did produce exactly the intended log: a single
Rate limited (403). resource=core remaining=0 reset=2026-08-19 16:33:05+00:00line followed by the run stopping, with zeroFailed to get comments ... rate limitlines (the old behaviour produced ~2,500 doomed requests).Final CI run on this PR: all four pipelines green.
Smoke mode: limited to 25 repositories, all 7 github resources completed in 21 min, 545,702 rows, no rate-limit spam.