Invalid JSON messages triggers an unhandled exception in JsonWebsocketConsumer and AsyncJsonWebsocketConsumer
Author: JulienPalardCreated Apr 9, 2026Updated Jun 27, 2026
Hi!
On malformed json sent by clients to JsonWebsocketConsumer or AsyncJsonWebsocketConsumer, a JSONDecodeError is raised and left unhandled.
The unhandled exception stops the django process (which will be restarted by Daphne so that's OKish).
But this looks fragile to me: a malicious user could spam malformed messages, with various effects like having the admin inbox to quickly fill if AdminEmailHandler is used.
I think malformed messages should be logged and ignored, but not raise an unhandled exception, what do you think?
Source: django/channels