Latest Results
fix(types): enforce tz-aware `DateTime` on Python >= 3.13
`prefect.types._datetime.DateTime` was supposed to be a Pydantic-validated,
tz-aware datetime regardless of Python version, but the 3.13+ branch aliased
to bare `datetime.datetime` — and Pydantic does not enforce tz-awareness on
that type. A naive value passed to any `DateTime`-typed field (e.g.
`Event.occurred` via `emit_event(..., occurred=datetime.now())`) reached the
server's SQL bind layer, was rejected with `Timestamps must have a timezone.`,
retried 5x by the in-memory bus, and silently dropped — the emitter saw no
error.
On Python <= 3.12 the pendulum-backed `PydanticDateTime` already coerces
naive datetimes to UTC during validation, so the bug was 3.13+ only.
On 3.13+, `DateTime` is now a `datetime.datetime` subclass whose Pydantic
core schema reuses the existing `create_datetime_instance` helper as an
after-validator. Every field typed as `DateTime` (or `Annotated[DateTime,
...]`) inherits the guarantee. Runtime construction (`DateTime(2020, 1, 1)`)
preserves bare `datetime.datetime` semantics — the coercion is a
validation-time concern.
closes #2194921949-event-occurred-naive-datetime fix(types): enforce tz-aware `DateTime` on Python >= 3.13
`prefect.types._datetime.DateTime` was supposed to be a Pydantic-validated,
tz-aware datetime regardless of Python version, but the 3.13+ branch aliased
to bare `datetime.datetime` — and Pydantic does not enforce tz-awareness on
that type. A naive value passed to any `DateTime`-typed field (e.g.
`Event.occurred` via `emit_event(..., occurred=datetime.now())`) reached the
server's SQL bind layer, was rejected with `Timestamps must have a timezone.`,
retried 5x by the in-memory bus, and silently dropped — the emitter saw no
error.
On Python <= 3.12 the pendulum-backed `PydanticDateTime` already coerces
naive datetimes to UTC during validation, so the bug was 3.13+ only.
This change fixes it at the type level — `DateTime` on 3.13+ is now a
`datetime.datetime` subclass whose Pydantic core schema runs a
`no_info_after_validator_function` that coerces naive values to UTC. Every
field typed as `DateTime` (or `Annotated[DateTime, ...]`) inherits the
guarantee instead of relying on ad-hoc per-field validators.
Runtime construction (`DateTime(2020, 1, 1)`) preserves bare
`datetime.datetime` semantics — the coercion is a validation-time concern.
closes #2194921949-event-occurred-naive-datetime Latest Branches
0%
devin/1778779716-fix-subflow-duplicate-on-restart 0%
saschwartz:fix/reject-terminal-state-data-overwrite 0%
21949-event-occurred-naive-datetime © 2026 CodSpeed Technology