-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Trying to deserialize certain misformatted strings result in an uncaught OverflowError exception instead of passing through the string unchanged. In particular, trying to deserialize a timedelta string such as "50001140846:00021" results in the following:
Traceback (most recent call last):
File "lib\site-packages\kiota_abstractions\date_utils.py", line 66, in parse_timedelta_string
return parse_timedelta_from_iso_format(text)
File "lib\site-packages\kiota_abstractions\date_utils.py", line 34, in parse_timedelta_from_iso_format
raise ValueError(f"Invalid ISO8601 duration string: {text}")
ValueError: Invalid ISO8601 duration string: 50001140846:00021
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
[...]
File "lib\site-packages\kiota_serialization_json\json_parse_node.py", line 335, in try_get_anything
return parse_timedelta_string(value)
File "lib\site-packages\kiota_abstractions\date_utils.py", line 76, in parse_timedelta_string
return timedelta(hours=hours, minutes=minutes, seconds=seconds)
OverflowError: days=2083380868; must have magnitude <= 999999999
The issue is that JsonParseNode.try_get_anything() only handles ValueError exceptions instead of also handling OverflowError. Changing this line to catch both ValueError and OverflowError allows deserialization to be successful:
kiota-python/packages/serialization/json/kiota_serialization_json/json_parse_node.py
Line 336 in b23edcb
| except ValueError: |
Most likely the other catch handlers in try_get_anything() should be updated as well.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Needs Triage 🔍