eclipse-velocitas / vehicle-app-python-sdk

vehicle-app-python-sdk
Apache License 2.0
7 stars 18 forks source link

[Bug]: SDK crashes in case of reading wrong characters from MQTT-broker #97

Closed sdvbernd closed 12 months ago

sdvbernd commented 1 year ago

Severity

High

What release version, tag or commit-hash did you use?

latest

Current Behavior

The following exception causes the complete application to crash:

{"stream":"stderr","log":"Exception in thread Thread-3 (_thread_main):\n","time":"2023-08-23T05:36:35.369153375Z"} {"stream":"stderr","log":"Traceback (most recent call last):\n","time":"2023-08-23T05:36:35.3692995Z"} {"stream":"stderr","log":" File \"threading.py\", line 1016, in _bootstrap_inner\n","time":"2023-08-23T05:36:35.3693405Z"} {"stream":"stderr","log":" File \"threading.py\", line 953, in run\n","time":"2023-08-23T05:36:35.369369625Z"} {"stream":"stderr","log":" File \"paho/mqtt/client.py\", line 3591, in _thread_main\n","time":"2023-08-23T05:36:35.36950125Z"} {"stream":"stderr","log":" File \"paho/mqtt/client.py\", line 1756, in loop_forever\n","time":"2023-08-23T05:36:35.369580125Z"} {"stream":"stderr","log":" File \"paho/mqtt/client.py\", line 1164, in _loop\n","time":"2023-08-23T05:36:35.36977275Z"} {"stream":"stderr","log":" File \"paho/mqtt/client.py\", line 1556, in loop_read\n","time":"2023-08-23T05:36:35.369903625Z"} {"stream":"stderr","log":" File \"paho/mqtt/client.py\", line 2439, in _packet_read\n","time":"2023-08-23T05:36:35.37008025Z"} {"stream":"stderr","log":" File \"paho/mqtt/client.py\", line 3033, in _packet_handle\n","time":"2023-08-23T05:36:35.3702365Z"} {"stream":"stderr","log":" File \"paho/mqtt/client.py\", line 3327, in _handle_publish\n","time":"2023-08-23T05:36:35.370446375Z"} {"stream":"stderr","log":" File \"paho/mqtt/client.py\", line 3556, in _handle_on_message\n","time":"2023-08-23T05:36:35.370536Z"} {"stream":"stderr","log":" File \"sdv/native/mqtt.py\", line 78, in handle\n","time":"2023-08-23T05:36:35.37064Z"} {"stream":"stderr","log":"UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 15: invalid continuation byte\n","time":"2023-08-23T05:36:35.370898625Z"}

The root cause here is that my app has been registered to a certain MQTT-topic and I have published a wrong character to the MQTT-broker by mistake. This wrong character was read inside the SDK and causes the crash of a thread. Afterwards the app was dead.

Steps to Reproduce

  1. Register to an MQTT-topic
  2. Push an unexpected character to the MQTT-broker

I have pushed the following:

mosquitto_pub -t seatadjuster/setPosition/request -m '{"position": 10�0, "requestId": 121}'

Expected Behavior

App should not crash

Possible Solution

No response

Additional Information

No response

Code of Conduct

sdvbernd commented 1 year ago

A wrong value also causes the SDV-kit to be crashed. The thread seems to stop an no further command can be sent to the MQTT-broker. Have a look at the following exception:

{"stream":"stderr","log":"Traceback (most recent call last):\n","time":"2023-08-23T11:52:06.8335745Z"} {"stream":"stderr","log":" File \"sdv/model.py\", line 137, in _set\n","time":"2023-08-23T11:52:06.833603875Z"} {"stream":"stderr","log":" File \"sdv/model.py\", line 435, in create_broker_data_point\n","time":"2023-08-23T11:52:06.83363025Z"} {"stream":"stderr","log":"ValueError: Value out of range: -10\n","time":"2023-08-23T11:52:06.83365775Z"}

MP91 commented 1 year ago

Hey @sdvbernd I just tried to reproduce this error locally.

I don't get an exception and the app is also not crashing. Since the error at the end comes from the paho mqtt client: which version of mosquitto are you using?