-
Notifications
You must be signed in to change notification settings - Fork 647
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
[asgi] Headers with special characters cause the request to fail #1814
Comments
I'm happy to submit a PR to fix this bug. However, I'm not sure what's the right fix is here. Changing decode from |
This issue is biting my product as well; seems like the PR has been up in 'draft' for well over a year now. How can we get this through the finish line? |
Seems like the original author of the PR is no longer working on it. Anyone can feel free to open up a pr to address this issue. |
Hi, I noticed some alerts pouring in on Sentry while setting up OpenTelemetry integration.
TL;DR:
A FastAPI instrumented app will throw an error with the following request:I dug deeper and found that this issue does not exist in the Flask instrumentation. Werkzeug's implementation uses
http.client.parse_headers
which has already decoded headers asiso-8859-1
before being passed to the instrumentor. Meanwhile, the ASGI instrumentor receives headers as bytes and incorrectly tires to decode headers asutf-8
which causes this error.Describe your environment
Python version: 3.10.10
OS: Manjaro
Steps to reproduce
server.py
server.py
client.py
client.py
Curl equivalent:
curl 'http://localhost:1234' -H $'X-Custom-Header: \xe9'
What is the expected behavior?
Client side input shouldn't cause the request to fail.
What is the actual behavior?
Request fails with "Internal Server Error"
Traceback
The text was updated successfully, but these errors were encountered: