Websocket returning 500 instead of 4XX when unable to resolve the path
- Dominant language
- Python
- Stars
- 6.4k
- Forks
- 826
- PR merge metrics
- No merged PRs in 30d
Description
What is the expected behavior when attempting to access a path not available in `websocket_urlpatterns`?
Currently my application will cause a status code 500 and I would hope to have a 404 (or 403) instead.
HOW TO REPRODUCE:
- Recreate the tutorial chat app up to the second step: https://channels.readthedocs.io/en/latest/tutorial/part_2.html
- Modify the path `path(r"ws/chat//", consumers.ChatConsumer.as_asgi())`
Now connecting to a room using int will behave normally:
- Create a room named 42: `WebSocket CONNECT /ws/chat/42/ [127.0.0.1:57662]`
But when attempting to create a room with a non-int name, the behavior seems strange.
EXPECTED BEHAVIOR
- Create a room named "banana": `WebSocket REJECT /ws/chat/banana/.` (status 403)
CURRENT BEHAVIOR
- Create a room named "banana": `ValueError: No route found for path 'ws/chat/banana/'.` (status 500)
Contributor guide
Assessment
This issue has not been assessed yet.