-
Notifications
You must be signed in to change notification settings - Fork 44
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
UnboundLocalError - chunk_size
is not always set in middleware method
#1335
Comments
Written a few tests to try to trigger this, but even with an empty |
Huh - you can see the error from a test in the gateway repository here. If it's not the content of the |
Right, hadn't appreciated the timeout aspect. Well #1336 should fix it either way, but probably not something we can test here |
Just noticed that we are running into the exact same bug with FastAPI 0.85 here: #1334 |
Going to reopen this until I can verify that most responses still have an appropriate chunk size, not the default of 1 byte |
Seems fine! Tested by adding a breakpoint in the case of |
So very much appreciated! Thank you! ❤️ |
In the
AddWarnings
middleware, thechunk_size
variable may not always be set, resulting in anUnboundLocalError
exception being thrown.The relevant lines of code can be found here.
The issue is (my guess), if the body is empty the for-loop is never entered, hence
chunk_size
is not set.Solution: Any variables always reached should be preset at the beginning of functions/methods.
The text was updated successfully, but these errors were encountered: