auto-pi-lot / autopilot

Distributed behavioral experiments
https://docs.auto-pi-lot.com
Mozilla Public License 2.0
93 stars 24 forks source link

_deserialize_numpy raises uncaught ValueError for non-compressed data #188

Open cxrodgers opened 2 years ago

cxrodgers commented 2 years ago

I get this error:

                  File "/home/pi/dev/autopilot/autopilot/networking/node.py", line 194, in handle_listen
                    msg = Message(msg[-1], expand_arrays=self.expand)
                  File "/home/pi/dev/autopilot/autopilot/networking/message.py", line 77, in __init__
                    deserialized = json.loads(msg, object_pairs_hook=self._deserialize_numpy)
                  File "/usr/lib/python3.9/json/__init__.py", line 359, in loads
                    return cls(**kw).decode(s)
                  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
                    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
                  File "/usr/lib/python3.9/json/decoder.py", line 353, in raw_decode
                    obj, end = self.scan_once(s, idx)
                  File "/home/pi/dev/autopilot/autopilot/networking/message.py", line 147, in _deserialize_numpy
                    arr = blosc.unpack_array(decode)
                  File "/home/pi/.venv/autopilot/lib/python3.9/site-packages/blosc2/core.py", line 367, in unpack_array
                    pickled_array = decompress(packed_array)
                  File "/home/pi/.venv/autopilot/lib/python3.9/site-packages/blosc2/core.py", line 170, in decompress
                    return blosc2_ext.decompress(src, dst, as_bytearray)
                  File "blosc2_ext.pyx", line 440, in blosc2.blosc2_ext.decompress
                  File "blosc2_ext.pyx", line 406, in blosc2.blosc2_ext._check_comp_length
                ValueError: src cannot be less than 16 byte

Problem is uncaught ValueError here: https://github.com/auto-pi-lot/autopilot/blob/04b5968ba02c8a1413a27eb6a138b6a186b130f1/autopilot/networking/message.py#L147

Fix is here (catch ValueError in addition to RuntimeError): https://github.com/Rodgers-PAC-Lab/autopilot/blob/20decc5168ba2613f973a4c044101542dee47879/autopilot/networking/message.py#L148