#2147·channels

Websocket returning 500 instead of 4XX when unable to resolve the path

Author: sprezz-arthurCreated Apr 5, 2025Updated May 17, 2025

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:

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)