A client bug sent "settled_at": true instead of a timestamp, and the payment was stored as settled one second after midnight on 1 January 1970. A DateTime field in timestamp format treats True as 1 and False as 0 instead…
A client bug sent "settled_at": true instead of a timestamp, and the payment was stored as settled one second after midnight on 1 January 1970. A DateTime field in timestamp format treats True as 1 and False as 0 instead of rejecting them.
from marshmallow import fields
fields.DateTime(format="timestamp").deserialize(True)
fields.DateTime(format="timestamp").deserialize(False)
Both raise ValidationError: Not a valid datetime.
They return datetime.datetime(1970, 1, 1, 0, 0, 1) and datetime.datetime(1970, 1, 1, 0, 0).
format="timestamp_ms".1 and 0 are valid timestamps and must stay valid, and so must the text "1".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
timestamp-accepts-booleans
Changes under src/ are evaluated.