Skip to content

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

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

Closed
raphaelm opened this issue May 22, 2020 · 0 comments · Fixed by #701
Closed

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

raphaelm opened this issue May 22, 2020 · 0 comments · Fixed by #701

Comments

@raphaelm
Copy link

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

untitaker added a commit that referenced this issue Jun 3, 2020
…701)

Found multiple issues with the asgi middleware:

    lack of warning if contextvars are broken -- as part of that I refactored/unified the error message we give in such situations, also added more information as gevent just recently released a version that deals with contextvars better
    exposed methods that were meant for overriding.. but all that is done in there can be done in event processors, so we make them private

Fix #630
Fix #700
Fix #694
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant