From 50896bdb8a99b844397879e8112a72fb7f2b8be9 Mon Sep 17 00:00:00 2001 From: Forest Anderson Date: Sun, 21 Jun 2020 17:51:01 -0400 Subject: [PATCH] Added extra error for when bytes_data is revieved --- channels/generic/websocket.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/channels/generic/websocket.py b/channels/generic/websocket.py index 8cc8d1636..e0ccba4fe 100644 --- a/channels/generic/websocket.py +++ b/channels/generic/websocket.py @@ -123,6 +123,8 @@ class JsonWebsocketConsumer(WebsocketConsumer): def receive(self, text_data=None, bytes_data=None, **kwargs): if text_data: self.receive_json(self.decode_json(text_data), **kwargs) + elif not text_data and bytes_data: + raise ValueError("No text section for incoming WebSocket frame! There is a bytes section, however. Did you mean for it to be the text section?") else: raise ValueError("No text section for incoming WebSocket frame!") @@ -257,6 +259,8 @@ class AsyncJsonWebsocketConsumer(AsyncWebsocketConsumer): async def receive(self, text_data=None, bytes_data=None, **kwargs): if text_data: await self.receive_json(await self.decode_json(text_data), **kwargs) + elif not text_data and bytes_data: + raise ValueError("No text section for incoming WebSocket frame! There is a bytes section, however. Did you mean for it to be the text section?") else: raise ValueError("No text section for incoming WebSocket frame!")