Skip to content

Conversation

@luqven
Copy link
Owner

@luqven luqven commented Dec 29, 2025

Summary

Add automatic retry with exponential backoff for GitHub API rate limits (HTTP 429).

Changes

Modified: src/api/mod.rs

  • RateLimitError struct with reset time info and Display impl for user-friendly messages
  • parse_rate_limit_headers() - Extract X-RateLimit-* headers from response
  • is_rate_limited() - Detect rate limiting (429 or 403 with rate limit headers)
  • send_with_retry() - Automatic retry with exponential backoff

Behavior

  • Retries up to 3 times with 1s, 2s, 4s delays
  • Handles both HTTP 429 and GitHub's 403-with-rate-limit-headers pattern
  • Returns RateLimitError with helpful message: "Try again in X minutes"

Tests

6 new tests:

  • test_rate_limit_error_display_with_reset / without_reset
  • test_send_with_retry_success_first_try
  • test_send_with_retry_rate_limit_then_success
  • test_send_with_retry_exhausted
  • test_send_with_retry_403_with_rate_limit

Stacked PR Chain: smart-log

PR Title Merges Into
#35 feat: add stack discovery API -
#36 👉feat: add rate limit retry logic #35
#37 feat: add identifier detection and prompts #36
#38 feat: add gh CLI helpers #37
#39 feat: make log and status identifier optional with branch inference #38
#40 docs: update log and status documentation for smart defaults #39
#41 perf: optimize stack discovery with batch fetch #40
#42 perf: parallelize status check fetches #41

Add automatic retry with exponential backoff for GitHub API rate limits.

New functionality in src/api/mod.rs:
- RateLimitError struct with reset time info and Display impl
- parse_rate_limit_headers() to extract X-RateLimit-* headers
- is_rate_limited() to detect 429 and 403 with rate limit headers
- send_with_retry() for automatic retry with exponential backoff

Retries up to 3 times with 1s, 2s, 4s delays before returning
a RateLimitError with helpful message showing when to retry.

Includes 6 new tests for retry logic.
@luqven
Copy link
Owner Author

luqven commented Dec 30, 2025

Landed via #42

@luqven luqven closed this Dec 30, 2025
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