-
Notifications
You must be signed in to change notification settings - Fork 13
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
KeyError in default_429 when using TestClient #14
Comments
https://asgi.readthedocs.io/en/latest/specs/www.html#response-start-send-event Yes, this is a error in starlette. It should use |
abersheeran
added a commit
to abersheeran/starlette
that referenced
this issue
Jun 15, 2021
hidraco
added a commit
to hidraco/starlette
that referenced
this issue
Apr 21, 2022
* Fixed abersheeran/asgi-ratelimit#14 * lint it * Black it Co-authored-by: euri10 <[email protected]>
dudleyhunt86
added a commit
to dudleyhunt86/starlette-develop-with-python
that referenced
this issue
Oct 7, 2022
* Fixed abersheeran/asgi-ratelimit#14 * lint it * Black it Co-authored-by: euri10 <[email protected]>
azurelotus0926
added a commit
to azurelotus0926/starlette
that referenced
this issue
Jun 27, 2024
* Fixed abersheeran/asgi-ratelimit#14 * lint it * Black it Co-authored-by: euri10 <[email protected]>
github-actions bot
pushed a commit
to Kludex/jik
that referenced
this issue
Aug 16, 2024
* Fixed abersheeran/asgi-ratelimit#14 * lint it * Black it Co-authored-by: euri10 <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
default_429
function works fine when I launch my FastAPI app normally and send requests to it, but when I test it using FastAPI's (which is Starlette's)TestClient
, the firstsend
statement (await send({"type": "http.response.start", "status": 429})
) results in a KeyError. Normally when the firstsend
is called, the following headers are in the response in my app even if I don't specify aheaders
parameter insend
:But when the
TestClient
is used to test the endpoints, there are no headers and Starlette raises the following exception:This is because when using TestClient, the message that goes through
default_429
has no headers and results in an error. I easily solved this issue by supplying my own function foron_blocked
:I don't know if this counts as a Starlette issue or an ASGI-Ratelimit one, but thought I should put this here in case someone else faces a similar error.
The text was updated successfully, but these errors were encountered: