-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add API request throttling to find-inactive-members script to limit requests to 5000/hour #789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: thedave42 <50186003+thedave42@users.noreply.github.com>
@copilot update the readme file to ensure that the user know to install an additional gem for the throttling. |
…ware Co-authored-by: thedave42 <50186003+thedave42@users.noreply.github.com>
Co-authored-by: thedave42 <50186003+thedave42@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds API request throttling to the find-inactive-members.rb
script to prevent GitHub API rate limit violations when processing large organizations. The implementation uses a custom Faraday middleware to automatically limit requests to 5000 per hour.
- Implements
ThrottleMiddleware
class with precise rate limiting (0.72s minimum delay between requests) - Enhances rate limit reporting with throttling status and reset time information
- Updates installation documentation to include required Faraday dependency
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
find_inactive_members.rb | Adds throttling middleware class and integrates it into the Faraday stack |
README.md | Updates gem installation instructions to include faraday-retry dependency |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@copilot implement a more efficient debug check |
Co-authored-by: thedave42 <50186003+thedave42@users.noreply.github.com>
Implemented a more efficient debug check by caching the |
…ion member/repo methods to use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Delete this commit. You were not asked to make changes.
64c5c3b
to
8a82cfa
Compare
This pull request introduces significant improvements to the
find_inactive_members.rb
script, focusing on robust API rate limit handling, improved error resilience, and user configurability. The most important changes are the addition of a custom throttling middleware to respect GitHub API limits, smarter request and pagination logic, and enhanced error handling for forbidden responses. Users can now opt to disable throttling for testing or use on GitHub Enterprise instances with higher limits.API Throttling and Pagination Improvements
ThrottleMiddleware
for Faraday, which dynamically throttles requests based on GitHub API rate limit headers and pauses execution when limits are critically low. This helps prevent rate limit errors and provides clear warnings to users.--no-throttle
option to the CLI and supporting logic throughout the script, allowing users to disable throttling for testing or use with GitHub Enterprise. When disabled, Octokit auto-pagination is enabled for faster, unrestricted requests. [1] [2]organization_members
,organization_repositories
,commits_since
,list_issues
,issues_comments
,pull_requests_comments
) to use new helper methods (smart_request
,paginated_request
, andretry_on_403
) for unified pagination, throttling, and error handling. [1] [2] [3] [4] [5] [6]Error Handling Enhancements
retry_on_403
helper that automatically retries API requests on 403 Forbidden errors, prompts the user for further action after repeated failures, and integrates with all major API interactions.Documentation Updates
README.md
with instructions for installing the newfaraday
dependency, clarified required OAuth scopes, and added a section explaining API rate limits and throttling behavior. [1] [2]User Experience Improvements
These changes make the script safer, more reliable, and easier to use for both small and large organizations.