Skip to content

SentryAsgiMiddleware requires missing scope key "method" on websocket events #700

@raphaelm

Description

@raphaelm

When using SentryAsgiMiddleware, Sentry fails for us because it does not find a method key on the scope object of Websocket connections:

server_1  | 2020-05-22 11:29:00,758 ERROR 140587441231616 sentry_sdk.errors hub Internal error in sentry_sdk
server_1  | Traceback (most recent call last):
server_1  |   File "/usr/local/lib/python3.8/site-packages/sentry_sdk/scope.py", line 326, in apply_to_event
server_1  |     new_event = event_processor(event, hint)
server_1  |   File "/usr/local/lib/python3.8/site-packages/sentry_sdk/integrations/asgi.py", line 126, in event_processor
server_1  |     request_info["method"] = asgi_scope["method"]
server_1  | KeyError: 'method'

The ASGI spec does not mandate such a method key:
https://asgi.readthedocs.io/en/latest/specs/www.html#id1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions