open-telemetry / open-telemetry/opentelemetry-python-contrib
Improper status code handling between flask and wsgi instrumentation: bare status codes.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Flask's Response type status field can be just a simple string or an integer but the wsgi instrumentation here expects it to be able to be split on a string (understandable as that's wsgi / pep 3333 compliant).
Can blow up in this manner:
File "/usr/local/lib/python/dist-packages/flask/app.py", line 2453, in wsgi_app
return response(environ, start_response)
File "/usr/local/lib/python/dist-packages/werkzeug/wrappers/base_response.py", line 701, in __call__
start_response(status, headers)
File "/usr/local/lib/python/dist-packages/opentelemetry/instrumentation/flask/__init__.py", line 109, in _start_response
span, status, response_headers
File "/usr/local/lib/python/dist-packages/opentelemetry/instrumentation/wsgi/__init__.py", line 163, in add_response_attributes
status_code, _ = start_response_status.split(" ", 1)
ValueError: not enough values to unpack (expected 2, got 1)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/init.py around lines 107-110 and the WSGI add_response_attributes entry point. Reproduce the failure with a Flask response using a bare status string or integer, then verify instrumentation handles it without the split error while preserving response status attributes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100