Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erro lidando com evento None AttributeError: 'NoneType' object has no attribute 'name' #2

Open
gbromulorosa opened this issue Feb 19, 2020 · 0 comments

Comments

@gbromulorosa
Copy link
Contributor

Quando o protocolo de eventos tenta processar um event None, este levanta AttributeError ao invés de EventParsingException

{"level": "ERROR", "message": "Error in parser schema procedure", "context": {"id": null, "flow_id": null, "event_name": null}, "extra": {"event": "null"}, "stacktrace": "\"Traceback (most recent call last):\\n  File \\\"/home/romulorosa/.local/lib/python3.7/site-packages/events_protocol/server/parser/event_processor.py\\\", line 37, in parse_event\\n    event = cls.event_validator.from_json(str_event)\\n  File \\\"/home/romulorosa/.local/lib/python3.7/site-packages/events_protocol/core/model/base.py\\\", line 86, in from_json\\n    _data = json.loads(data)\\n  File \\\"/usr/lib/python3.7/json/__init__.py\\\", line 341, in loads\\n    raise TypeError(f'the JSON object must be str, bytes or bytearray, '\\nTypeError: the JSON object must be str, bytes or bytearray, not NoneType\""}
Traceback (most recent call last):
  File "/home/romulorosa/.local/lib/python3.7/site-packages/events_protocol/server/parser/event_processor.py", line 37, in parse_event
    event = cls.event_validator.from_json(str_event)
  File "/home/romulorosa/.local/lib/python3.7/site-packages/events_protocol/core/model/base.py", line 86, in from_json
    _data = json.loads(data)
  File "/usr/lib/python3.7/json/__init__.py", line 341, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/romulorosa/.local/lib/python3.7/site-packages/events_protocol/server/parser/event_processor.py", line 26, in process_event
    event: Event = cls.parse_event(raw_event)
  File "/home/romulorosa/.local/lib/python3.7/site-packages/events_protocol/server/parser/event_processor.py", line 53, in parse_event
    raise EventParsingException(dict(error="Unknown error"))
events_protocol.core.exception.EventParsingException: ('INVALID_COMMUNICATION_PROTOCOL', {'error': 'Unknown error'}, <EventErrorType.BAD_PROTOCOL: 'badProtocol'>, False)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/romulorosa/.local/lib/python3.7/site-packages/events_protocol/server/parser/event_processor.py", line 32, in process_event
    return EventBuilder.error_for(exception, event).to_json()
  File "/home/romulorosa/.local/lib/python3.7/site-packages/events_protocol/core/builder.py", line 26, in error_for
    if event.name
AttributeError: 'NoneType' object has no attribute 'name'

Código de replicação

from events_protocol.server.parser.event_processor import EventProcessor
EventProcessor.process_event(None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant