limx0 / betfair_parser

BSD 2-Clause "Simplified" License
6 stars 1 forks source link

Invalid sizeLapsed #53

Closed ml31415 closed 4 months ago

ml31415 commented 9 months ago

Recently I stumbled upon a currentOrder object, that failed validation, seemingly due to an invalid sizeLapsed field.

Traceback (most recent call last):
  File "/home/michael/.local/lib/python3.10/site-packages/betfair_parser/spec/common/messages.py", line 17, in decode
    return msgspec.json.decode(raw, strict=False, type=type)
msgspec.ValidationError: Expected `float` >= 0.0 - at `$.result.currentOrders[62].sizeLapsed`

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
...
  File "/home/michael/.local/lib/python3.10/site-packages/betfair_parser/spec/common/messages.py", line 197, in parse_response
    resp = decode(response, type=self.return_type)
  File "/home/michael/.local/lib/python3.10/site-packages/betfair_parser/spec/common/messages.py", line 19, in decode
    raise JSONError(str(e)) from e
betfair_parser.exceptions.JSONError: Expected `float` >= 0.0 - at `$.result.currentOrders[62].sizeLapsed`

This seems to be a very rare event. Though, it once again shows the limitations of current msgspec error handling ( https://github.com/jcrist/msgspec/issues/420 and https://github.com/jcrist/msgspec/issues/264 ). We might have to parse these $.result.currentOrders[62].sizeLapsed path strings manually and use them to extract the erroneous data from the JSON data parsed without any verification and validation as plain base types, to produce better error messages on our own.