-
Notifications
You must be signed in to change notification settings - Fork 102
Open
Description
Describe the bug
When initializing the Limiter with default_limits as a string instead of a list of strings, slowapi crashes with an unhandled AttributeError when a rate limit is exceeded.
To Reproduce
limiter = Limiter(key_func=get_remote_address, default_limits="1/second")
Expected behavior
If default_limits="1/second" is passed (as a string), slowapi should either:
- Handle it gracefully (e.g., by coercing it into a list), or
- Raise a clear and early error during initialization.
Error details
AttributeError: 'ValueError' object has no attribute 'detail'
&
# slowapi/extension.py (line 81 in _rate_limit_exceeded_handler)
{"error": f"Rate limit exceeded: {exc.detail}"}
Your app (please complete the following information):
- fastapi : 0.116.1
- slowapi version : 0.9.1 (latest version)
Metadata
Metadata
Assignees
Labels
No labels