project8 / dripline-python

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

messages with improper payload encoding crash services #11

Closed laroque closed 7 years ago

laroque commented 7 years ago

As a concrete example, if in php I send a message with the payload a "json object" (whatever native type that actually is) and not the json encoding of that object, I get the traceback that follows below.

The exception is not being handled because it is not an internal dripline exception. Should enclose the decoding procedure in a try block and raise a DriplineDecodingError (302) if needed.

2017-02-07T22:58:28[ERROR   ] dripline.core.service(430) -> Traceback (most recent call last):
  File "/home/laroque/python_environments/dripline/lib/python2.7/site-packages/dripline-wp2.1.1_python3.4.1_0_g9a348a4-py2.7.egg/dripline/core/service.py", line 427, in run
    self._connection.ioloop.start()
  File "build/bdist.linux-x86_64/egg/pika/adapters/select_connection.py", line 138, in start
    self.poller.start()
  File "build/bdist.linux-x86_64/egg/pika/adapters/select_connection.py", line 433, in start
    self.poll()
  File "build/bdist.linux-x86_64/egg/pika/adapters/select_connection.py", line 494, in poll
    self._handler(fileno, event, write_only=write_only)
  File "build/bdist.linux-x86_64/egg/pika/adapters/base_connection.py", line 322, in _handle_events
    self._handle_read()
  File "build/bdist.linux-x86_64/egg/pika/adapters/base_connection.py", line 351, in _handle_read
    self._on_data_available(data)
  File "build/bdist.linux-x86_64/egg/pika/connection.py", line 1285, in _on_data_available
    self._process_frame(frame_value)
  File "build/bdist.linux-x86_64/egg/pika/connection.py", line 1365, in _process_frame
    self._deliver_frame_to_channel(frame_value)
  File "build/bdist.linux-x86_64/egg/pika/connection.py", line 976, in _deliver_frame_to_channel
    return self._channels[value.channel_number]._handle_content_frame(value)
  File "build/bdist.linux-x86_64/egg/pika/channel.py", line 792, in _handle_content_frame
    self._on_deliver(*response)
  File "build/bdist.linux-x86_64/egg/pika/channel.py", line 886, in _on_deliver
    body)
  File "/home/laroque/python_environments/dripline/lib/python2.7/site-packages/dripline-wp2.1.1_python3.4.1_0_g9a348a4-py2.7.egg/dripline/core/service.py", line 323, in on_message
    message = Message.from_encoded(body, properties.content_encoding)
  File "/home/laroque/python_environments/dripline/lib/python2.7/site-packages/dripline-wp2.1.1_python3.4.1_0_g9a348a4-py2.7.egg/dripline/core/message.py", line 176, in from_encoded
    return cls.from_json(msg)
  File "/home/laroque/python_environments/dripline/lib/python2.7/site-packages/dripline-wp2.1.1_python3.4.1_0_g9a348a4-py2.7.egg/dripline/core/message.py", line 170, in from_json
    raise exceptions.DriplineDecodingError('unable to decode message; received: {}'.format(e.msg))
AttributeError: 'exceptions.AttributeError' object has no attribute 'msg'

2017-02-07T22:58:28[DEBUG   ] dripline.core.service(398) -> loop ended
guiguem commented 7 years ago

Solved with 7f37e2768e0942c82fc8da010919a20542ce947c