ValueError during timestamp parsing in rare case
wjh18 opened this issue · 1 comments
Describe the bug
Discovered a (rare?) bug whereby the API response contains an analysisUTCTimestamp
field with no trailing fractions of a second. When converting the timestamp to a Python datetime
object in this scenario, it causes: ValueError: time data '2023-03-29T07:09:31Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'
.
To Reproduce
Can reproduce in testing by supplying api.response._get_timestamp
with a mock JSON response dict (should contain a top-level analysisUTCTimestamp
item with no trailing fractions of a second in its value). Then assert that it raises ValueError
.
Expected behavior
Fractions of a second aren't used in report generation anyway so we should handle both scenarios gracefully (optional %f?).