Skip to content

feat: add rate limiting and 429 retry for API requests - #6

Merged
dsablic merged 4 commits into
dsablic:mainfrom
fabio-DigitalScience:feat/rate-limiting
Feb 23, 2026
Merged

dsablic merged 4 commits into
dsablic:mainfrom
fabio-DigitalScience:feat/rate-limiting

Conversation

@fabio-DigitalScience

Copy link
Copy Markdown
Collaborator

Summary

  • Add RateLimitTransport (http.RoundTripper) with configurable token-bucket rate limiting and automatic retry on 429 responses with exponential backoff / Retry-After header support
  • New --rate-limit CLI flag (default 0 = unlimited, retry-only) for both analyze and trends commands
  • Pass shared *http.Client to all provider constructors (GitLab, GitHub, Bitbucket) so rate limiting applies globally

Test results

Tested against digital-science/dimensions/grants GitLab group (399 repos):

  • Before: 867 errors (all 429 rate limit)
  • After (--rate-limit 3): 0 rate limit errors, 306 remaining errors (305 x 401 auth, 4 x 502 server — unrelated to rate limiting)

Test plan

  • go test ./... passes
  • Live test against 399-repo GitLab group with --rate-limit 3
  • Verify 0 rate limit (429) errors in error log
  • Test with --rate-limit 0 (default, retry-only mode)
  • Test against GitHub provider

🤖 Generated with Claude Code

fabio-DigitalScience and others added 4 commits February 23, 2026 11:22
When ListCommits returns an error (network, auth, rate limiting), repos
are now classified as "failed" instead of being silently marked
"abandoned". Failed repos are excluded from code percentage calculations
in the health summary to avoid skewing active/maintained/abandoned ratios.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Switch from PRIVATE-TOKEN header to Authorization Bearer for GitLab API
requests, and use `glab config get token` instead of `glab auth token`
for CLI token retrieval.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Write a <report>.error.log file (e.g., report.error.log) next to the
JSON report when API errors occur. Each line is prefixed with a category
([health], [health-details], [ai-estimate], [ai-estimate-detail]) for
easy filtering with grep.

Also adds RepoHealth.Error field to surface failure reasons in JSON
output, and propagates partial errors from AnalyzeDetails and Estimate.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add RateLimitTransport (http.RoundTripper) with configurable rate
limiting and automatic retry on 429 responses with exponential backoff.
Pass shared *http.Client to all provider constructors via --rate-limit
CLI flag. Tested against 399-repo GitLab group: 0 rate limit errors
(previously 867).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dsablic
dsablic merged commit 9fbaa4c into dsablic:main Feb 23, 2026
1 check passed
@fabio-DigitalScience
fabio-DigitalScience deleted the feat/rate-limiting branch February 23, 2026 13:52
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.

2 participants