host: raise a protocol error for empty messages
When decoding a message, first check that it is not empty and raise a `ProtocolError` otherwise. This prevent a more obscure error like "NoneType has no get method".
This commit is contained in:
parent
879c56a3b5
commit
6a39067772
1 changed files with 3 additions and 0 deletions
|
|
@ -78,6 +78,9 @@ class ServiceProtocol:
|
|||
|
||||
@staticmethod
|
||||
def decode_message(msg: Dict) -> Tuple[str, Dict]:
|
||||
if not msg:
|
||||
raise ProtocolError("message empty")
|
||||
|
||||
t = msg.get("type")
|
||||
if not t:
|
||||
raise ProtocolError("'type' field missing")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue