A partner sent a trade with "executed_at": 1e30 and our endpoint answered 500 instead of 400. A DateTime field in timestamp format lets very large numbers through to the system clock functions, and the exception they rai…
A partner sent a trade with "executed_at": 1e30 and our endpoint answered 500 instead of 400. A DateTime field in timestamp format lets very large numbers through to the system clock functions, and the exception they raise is not a validation error.
from marshmallow import fields
field = fields.DateTime(format="timestamp")
field.deserialize(1e30)
field.deserialize(10**17)
Both raise ValidationError: Not a valid datetime.
OverflowError: timestamp out of range for platform time_t
OSError: [Errno 75] Value too large for defined data type
format="timestamp_ms" has the same problem.253402300799 (the last second of the year 9999) loads, and one second later is already reported as invalid.Adapted from marshmallow-code/marshmallow (MIT).
Visible test command
pytest testsThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
huge-timestamp-crashes-load
Changes under src/ are evaluated.