Skip to content

Conversation

@Claude
Copy link
Contributor

@Claude Claude AI commented Feb 10, 2026

Pull Request

Proposed Changes

Implements configurable rate limiting to prevent workflow failures from exceeding GitHub API rate limits when processing multiple repositories.

Core Implementation

Rate Limiter Module (rate_limiter.py):

  • Token bucket algorithm for smooth request distribution
  • Exponential backoff on 429 responses (1s → 2s → 4s)
  • Thread-safe with lock-based synchronization
  • Wraps all requests library calls (GET, PUT, POST) and GraphQL queries

Configuration (defaults in parentheses):

  • RATE_LIMIT_ENABLED (true) - Toggle rate limiting
  • RATE_LIMIT_REQUESTS_PER_SECOND (2.0) - Max requests/second
  • RATE_LIMIT_BACKOFF_FACTOR (2.0) - Retry wait multiplier
  • RATE_LIMIT_MAX_RETRIES (3) - Max retry attempts

Integration Points:

  • is_dependabot_security_updates_enabled()
  • enable_dependabot_security_updates()
  • get_global_project_id(), get_global_issue_id(), get_global_pr_id()
  • link_item_to_project()

Usage Example

# Default behavior - automatically rate limited
rate_limiter = RateLimiter(requests_per_second=2.0, enabled=True)
response = rate_limiter.execute_with_backoff(requests.get, url, headers=headers)

# Disable rate limiting if needed
rate_limiter = RateLimiter(enabled=False)

Test Coverage

  • 142 tests passing (13 new)
  • 97% code coverage
  • Validates token bucket behavior, exponential backoff timing, thread safety, and configuration parsing

Readiness Checklist

Author/Contributor

  • If documentation is needed for this change, has that been included in this pull request
  • run make lint and fix any issues that you have introduced
  • run make test and ensure you have test coverage for the lines you are introducing
  • If publishing new data to the public (scorecards, security scan results, code quality results, live dashboards, etc.), please request review from @jeffrey-luszcz

Reviewer

  • Label as either fix, documentation, enhancement, infrastructure, maintenance or breaking
Original prompt

This section details on the original issue you should resolve

<issue_title>Rate Limiting</issue_title>
<issue_description>Would be great to implement rate limiting so users don't get failed workflow runs because it was zooming through repos too fast.

Rate limiting should be configurable and have an exponential backoff if limits are hit.</issue_description>

<agent_instructions>Be sure to use best practices for implementing rate limiting.

When I refer to rate limiting, I mean to say we should limit the number of requests per second we are sending to the github api.

It should be configurable to set the amount of rate limiting and to turn it off completely. It should be on by default though.</agent_instructions>

Comments on the Issue (you are @claude[agent] in this section)

@zkoppert Related to https://github.com/github/github-ospo/issues/77

Claude AI and others added 3 commits February 10, 2026 19:56
Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
- Add RateLimiter class with token bucket algorithm
- Add configurable rate limiting via environment variables
- Integrate rate limiting into all GitHub API calls
- Add comprehensive test suite for rate limiting
- Update environment variable handling and tests
- All tests passing with 97% code coverage

Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
- Document RATE_LIMIT_ENABLED environment variable
- Document RATE_LIMIT_REQUESTS_PER_SECOND environment variable
- Document RATE_LIMIT_BACKOFF_FACTOR environment variable
- Document RATE_LIMIT_MAX_RETRIES environment variable
- Add dedicated Rate Limiting section in configuration

Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Implement configurable rate limiting for GitHub API requests feat: add configurable rate limiting with exponential backoff Feb 10, 2026
@Claude Claude AI requested a review from zkoppert February 10, 2026 20:10
Signed-off-by: Zack Koppert <zkoppert@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rate Limiting

2 participants