Skip to content

Commit

Permalink
Ignore invalid ESS payloads with warning
Browse files Browse the repository at this point in the history
  • Loading branch information
leonhard-s committed May 15, 2021
1 parent e19c0d8 commit 2e05a64
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion auraxium/event/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import (Any, Callable, Coroutine, Dict, Iterator, List, Optional, Type, TypeVar, Union,
cast, overload)
import backoff
import pydantic

import websockets

Expand Down Expand Up @@ -376,7 +377,16 @@ def _process_payload(self, response: str) -> None:
# Event messages
if service == 'event':
if data['type'] == 'serviceMessage':
event = _event_factory(cast(CensusData, data['payload']))
try:
event = _event_factory(cast(CensusData, data['payload']))
except pydantic.ValidationError:
_log.warning(
'Ignoring unsupported payload: %s\n'
'This message means that the Auraxium data model must '
'be updated. Please ensure you are on the latest '
'version of the Auraxium library and report this '
'message to the project maintainers.', data['payload'])
return
_log.debug('%s event received, dispatching...',
event.event_name)
self.dispatch(event)
Expand Down

0 comments on commit 2e05a64

Please sign in to comment.