project8 / dripline-python

python implementation of project8/dripline
Other
2 stars 0 forks source link

message decoding error - crash #31

Closed wcpettus closed 6 years ago

wcpettus commented 6 years ago

In message.py, if dripline receives an ill-formatted json payload, it will crash because its except clause has an error: https://github.com/project8/dripline-python/blame/master/dripline/core/message.py#L160 (Exceptions don't have a "msg" attribute, they have "message")

I'm not sure if you want to be reading the error or the original message here, I blame past Ben.

wcpettus commented 6 years ago

Here's a recent example of it crashing things:

-----------------------------
2018-05-12T17:22:27[INFO    ] dripline.core.service(321) -> received a message
2018-05-12T17:22:27[DEBUG   ] dripline.core.service(362) -> Acknowledging message 1476
2018-05-12T17:22:27[DEBUG   ] dripline.core.message(154) -> original msg was: {"lockout_key":"","timestamp":"2018-05-12T17:22:24Z","msgop":9,"sender_info":{"hostname":"dorian-win7","username":"guigue","exe":"LabVIEW.exe","service_name":"","version":"","commit":"","package":""},"msgtype":3,"payload": {"values":}}
2018-05-12T17:22:27[ERROR   ] dripline.core.message(159) -> error while decoding message:
{"lockout_key":"","timestamp":"2018-05-12T17:22:24Z","msgop":9,"sender_info":{"hostname":"dorian-win7","username":"guigue","exe":"LabVIEW.exe","service_name":"","version":"","commit":"","package":""},"msgtype":3,"payload": {"values":}}
2018-05-12T17:22:27[INFO    ] dripline.core.service(552) -> sending an alert
2018-05-12T17:22:27[DEBUG   ] dripline.core.service(556) -> to status_message.error.rpi_gpio sending {
    "timestamp": "2018-05-13T00:22:27Z", 
    "payload": "error while decoding message:\n{\"lockout_key\":\"\",\"timestamp\":\"2018-05-12T17:22:24Z\",\"msgop\":9,\"sender_info\":{\"hostname\":\"dorian-win7\",\"username\":\"guigue\",\"exe\":\"LabVIEW.exe\",\"service_name\":\"\",\"version\":\"\",\"commit\":\"\",\"package\":\"\"},\"msgtype\":3,\"payload\": {\"values\":}}", 
    "sender_info": {
        "username": "project8", 
        "exe": "/home/project8/python_environments/latest_version/bin/dragonfly", 
        "package": "dripline", 
        "service_name": "unknown_service_ae7dded-b5b", 
        "hostname": "betty", 
        "version": "wp2.1.1", 
        "commit": "g76b0979"
    }
}
2018-05-12T17:22:27[CRITICAL] dripline.core.service(434) -> Service <rpi_gpio> crashing with error message:
'exceptions.ValueError' object has no attribute 'msg'
2018-05-12T17:22:27[INFO    ] dripline.core.service(552) -> sending an alert
2018-05-12T17:22:27[DEBUG   ] dripline.core.service(556) -> to status_message.critical.rpi_gpio sending {
    "timestamp": "2018-05-13T00:22:27Z", 
    "payload": "Service <rpi_gpio> crashing with error message:\n'exceptions.ValueError' object has no attribute 'msg'", 
    "sender_info": {
        "username": "project8", 
        "exe": "/home/project8/python_environments/latest_version/bin/dragonfly", 
        "package": "dripline", 
        "service_name": "unknown_service_ae7dded-b5b", 
        "hostname": "betty", 
        "version": "wp2.1.1", 
        "commit": "g76b0979"
    }
}
2018-05-12T17:22:27[ERROR   ] dripline.core.service(435) -> Traceback (most recent call last):
  File "/home/project8/python_environments/drag_v1.12.9_drip_wp2.1.1_python3.6.1_hard_v1.13.7/local/lib/python2.7/site-packages/dripline/core/service.py", line 432, in run
    self._connection.ioloop.start()
  File "/home/project8/python_environments/drag_v1.12.9_drip_wp2.1.1_python3.6.1_hard_v1.13.7/local/lib/python2.7/site-packages/pika/adapters/select_connection.py", line 138, in start
    self.poller.start()
  File "/home/project8/python_environments/drag_v1.12.9_drip_wp2.1.1_python3.6.1_hard_v1.13.7/local/lib/python2.7/site-packages/pika/adapters/select_connection.py", line 433, in start
    self.poll()
  File "/home/project8/python_environments/drag_v1.12.9_drip_wp2.1.1_python3.6.1_hard_v1.13.7/local/lib/python2.7/site-packages/pika/adapters/select_connection.py", line 494, in poll
    self._handler(fileno, event, write_only=write_only)
  File "/home/project8/python_environments/drag_v1.12.9_drip_wp2.1.1_python3.6.1_hard_v1.13.7/local/lib/python2.7/site-packages/pika/adapters/base_connection.py", line 322, in _handle_events
    self._handle_read()
  File "/home/project8/python_environments/drag_v1.12.9_drip_wp2.1.1_python3.6.1_hard_v1.13.7/local/lib/python2.7/site-packages/pika/adapters/base_connection.py", line 351, in _handle_read
    self._on_data_available(data)
  File "/home/project8/python_environments/drag_v1.12.9_drip_wp2.1.1_python3.6.1_hard_v1.13.7/local/lib/python2.7/site-packages/pika/connection.py", line 1285, in _on_data_available
    self._process_frame(frame_value)
  File "/home/project8/python_environments/drag_v1.12.9_drip_wp2.1.1_python3.6.1_hard_v1.13.7/local/lib/python2.7/site-packages/pika/connection.py", line 1365, in _process_frame
    self._deliver_frame_to_channel(frame_value)
  File "/home/project8/python_environments/drag_v1.12.9_drip_wp2.1.1_python3.6.1_hard_v1.13.7/local/lib/python2.7/site-packages/pika/connection.py", line 976, in _deliver_frame_to_channel
    return self._channels[value.channel_number]._handle_content_frame(value)
  File "/home/project8/python_environments/drag_v1.12.9_drip_wp2.1.1_python3.6.1_hard_v1.13.7/local/lib/python2.7/site-packages/pika/channel.py", line 792, in _handle_content_frame
    self._on_deliver(*response)
  File "/home/project8/python_environments/drag_v1.12.9_drip_wp2.1.1_python3.6.1_hard_v1.13.7/local/lib/python2.7/site-packages/pika/channel.py", line 886, in _on_deliver
    body)
  File "/home/project8/python_environments/drag_v1.12.9_drip_wp2.1.1_python3.6.1_hard_v1.13.7/local/lib/python2.7/site-packages/dripline/core/service.py", line 328, in on_message
    message = Message.from_encoded(body, properties.content_encoding)
  File "/home/project8/python_environments/drag_v1.12.9_drip_wp2.1.1_python3.6.1_hard_v1.13.7/local/lib/python2.7/site-packages/dripline/core/message.py", line 169, in from_encoded
    return cls.from_json(msg)
  File "/home/project8/python_environments/drag_v1.12.9_drip_wp2.1.1_python3.6.1_hard_v1.13.7/local/lib/python2.7/site-packages/dripline/core/message.py", line 160, in from_json
    raise exceptions.DriplineDecodingError('unable to decode message; received: {}'.format(e.msg))
AttributeError: 'exceptions.ValueError' object has no attribute 'msg'
wcpettus commented 6 years ago

fixed in 3.6.2