slowapi
slowapi copied to clipboard
Exception: No "request" or "websocket" argument on function
Describe the bug If the rate limiter is not specifically instantiated as "limiter", it throws this error when adding an endpoint with the rate limiter decorator: Exception: No "request" or "websocket" argument on function
To Reproduce rate_limiter = Limiter(key_func=get_remote_address) app.state.limiter = rate_limiter app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
@app.get("/home") @rate_limiter .limit("5/minute") async def homepage(request: Request): return { "message": "Hello world", }
Expected behavior The object should function regardless of what variable it is instantiated under.
Screenshots If applicable, add screenshots to help explain your problem.
Your app (please complete the following information):
- fastapi or starlette? FastAPI
- Version? 0.104.1
- slowapi version (have you tried with the latest version)? 0.1.8 Additional context Add any other context about the problem here. I have just resorted to using the variable "limiter", which works fine.
ever get this working?
i got the same error; fastapi==0.109.2 slowapi==0.1.9
as i rename my api function params as 'request', i will pass the verification; its a not good verification