Skip to content

from_json with None crashes event stream #264

Description

@nisbus

When listening to the event stream for some reason some event is None.
When that happens, from_json crashes the stream subscription.

File "/lib/python3.7/site-packages/marathon/client.py", line 795, in event_stream
    yield ef.process(event_data)
  File "/lib/python3.7/site-packages/marathon/models/events.py", line 215, in process
    return clazz.from_json(event)
  File "/lib/python3.7/site-packages/marathon/models/base.py", line 43, in from_json
    return cls(**{to_snake_case(k): v for k, v in attributes.items()})
  File "/lib/python3.7/site-packages/marathon/models/events.py", line 36, in __init__
    self._set(attribute, kwargs.get(attribute))
  File "/lib/python3.7/site-packages/marathon/models/events.py", line 56, in _set
    attribute = self.__to_marathon_object(attribute_name, attribute)
  File "/lib/python3.7/site-packages/marathon/models/events.py", line 42, in __to_marathon_object
    attribute = clazz.from_json(attribute)
  File "/lib/python3.7/site-packages/marathon/models/base.py", line 43, in from_json
    return cls(**{to_snake_case(k): v for k, v in attributes.items()})
  File "/lib/python3.7/site-packages/marathon/models/deployment.py", line 74, in __init__
    self.original = MarathonDeploymentOriginalState.from_json(original)
  File "/lib/python3.7/site-packages/marathon/models/base.py", line 43, in from_json
    return cls(**{to_snake_case(k): v for k, v in attributes.items()})
AttributeError: 'NoneType' object has no attribute 'items'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions