Skip to content

Improper status code handling between flask and wsgi instrumentation: bare status codes. #575

Open
@tmc

Description

@tmc

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).

This line

if span:
otel_wsgi.add_response_attributes(
span, status, response_headers
)

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions