feat: add rate-limit retry/backoff handling in Gitea API client #145

Merged
AI-Manager merged 1 commits from feature/rate-limit-retry-132 into master 2026-03-28 19:03:25 +00:00
Owner

Summary

  • Add automatic retry logic to doRequest for HTTP 429 (Too Many Requests) responses
  • Respect Retry-After header when present, fall back to exponential backoff (1s, 2s, 4s)
  • Context cancellation is honored during retry waits
  • Configurable maxRetries (default 3) and baseRetryDelay (default 1s) on Client struct
  • Non-429 errors are not retried
  • Add 7 new tests covering all retry scenarios

Closes #132

Test plan

  • go test ./internal/gitea/ -run TestDoRequest_RateLimit - all pass
  • go test ./internal/gitea/ -run TestRetryDelay - all pass
  • go test ./internal/gitea/ - all existing tests still pass
  • Manual: trigger rate limiting against a real Gitea instance and observe retry behavior in logs
## Summary - Add automatic retry logic to `doRequest` for HTTP 429 (Too Many Requests) responses - Respect `Retry-After` header when present, fall back to exponential backoff (1s, 2s, 4s) - Context cancellation is honored during retry waits - Configurable `maxRetries` (default 3) and `baseRetryDelay` (default 1s) on Client struct - Non-429 errors are not retried - Add 7 new tests covering all retry scenarios Closes #132 ## Test plan - [x] `go test ./internal/gitea/ -run TestDoRequest_RateLimit` - all pass - [x] `go test ./internal/gitea/ -run TestRetryDelay` - all pass - [x] `go test ./internal/gitea/` - all existing tests still pass - [ ] Manual: trigger rate limiting against a real Gitea instance and observe retry behavior in logs
AI-Manager added 1 commit 2026-03-28 18:09:05 +00:00
Add automatic retry logic to doRequest for HTTP 429 responses. Uses
Retry-After header when present, otherwise exponential backoff
(1s, 2s, 4s). Respects context cancellation during waits. Defaults
to 3 max retries with 1s base delay. Includes 7 new tests covering
retry success, exhaustion, Retry-After header, context cancellation,
non-429 errors, and backoff calculation.

Closes leeworks-agents/gitea-mobile#132

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
AI-Manager merged commit f44390a75a into master 2026-03-28 19:03:25 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/gitea-mobile#145