Fix: exempt localhost from rate limits by default - #197
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds the ability to exempt specific IP addresses from rate limiting, with localhost IPs (127.0.0.1 and ::1) being exempt by default. This prevents rate limit issues when multiple services run on the same host and share the same IP address.
Key changes:
- Added
exempt_ipsparameter toRateLimitMiddlewarewith localhost as the default - Added
rate_limit_exempt_ipsconfiguration field toManagerSettings - Updated tests to explicitly disable localhost exemption where rate limit testing is needed
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/madsci_common/madsci/common/middleware.py |
Added exempt_ips parameter to middleware constructor and early-return logic in dispatch method for exempt IPs |
src/madsci_common/madsci/common/types/manager_types.py |
Added rate_limit_exempt_ips field to ManagerSettings for configuration |
src/madsci_common/madsci/common/manager_base.py |
Added logic to convert exempt IPs list to set and pass to middleware, plus logging support |
src/madsci_common/tests/test_middleware.py |
Added tests for default and custom exempt IPs, updated existing fixtures to disable localhost exemption |
src/madsci_common/tests/test_stress.py |
Updated stress test fixture to explicitly disable localhost exemption |
Configuration.md |
Added documentation for new RATE_LIMIT_EXEMPT_IPS configuration option across all managers |
.env.example |
Added example configuration entries for RATE_LIMIT_EXEMPT_IPS |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Info
Prevents overwhelming rate limits in situations where services are all running on the same host (and thus all have the same IP).
Developer Checklists
I have: