Skip to content

🐛 Bug Report: slowapi crashes when default_limits is not a list #239

@rAJ-2301

Description

@rAJ-2301

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions