fix: ensure string timestamps are converted to UTC in MessageTable model (#5881)

This commit is contained in:
Gabriel Luiz Freitas Almeida 2025-01-22 23:00:36 -03:00 committed by GitHub
commit f5929fe58e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -137,6 +137,10 @@ class MessageTable(MessageBase, table=True): # type: ignore[call-arg]
if value.tzinfo is None:
value = value.replace(tzinfo=timezone.utc)
return value.strftime("%Y-%m-%d %H:%M:%S %Z")
if isinstance(value, str):
# Make sure the timestamp is in UTC
value = datetime.fromisoformat(value).replace(tzinfo=timezone.utc)
return value.strftime("%Y-%m-%d %H:%M:%S %Z")
return value
@field_validator("flow_id", mode="before")