Skip to content

Commit

Permalink
Ensure ethstats plugin handles incorrect server responses
Browse files Browse the repository at this point in the history
  • Loading branch information
cburgdorf committed Nov 13, 2018
1 parent 9b9a832 commit e427ac2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion trinity/plugins/builtin/ethstats/ethstats_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def recv_handler(self) -> None:
try:
message: EthstatsMessage = self.deserialize_message(json_string)
except EthstatsException as e:
self.logger.info('Cannot parse message from server: %s' % e)
self.logger.warning('Cannot parse message from server: %s' % e)
return

await self.recv_queue.put(message)
Expand All @@ -84,6 +84,9 @@ def deserialize_message(self, json_string: str) -> EthstatsMessage:
except json.decoder.JSONDecodeError as e:
raise EthstatsException('Received incorrect JSON: %s' % e)

if isinstance(raw_message, str):
raise EthstatsException(f'Received invalid payload: {raw_message}')

try:
payload = raw_message['emit']
except KeyError:
Expand Down

0 comments on commit e427ac2

Please sign in to comment.