Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Taskiq version
0.12.1
Python version
Python 3.13
OS
macOS
What happened?
When serializing and subsequently validating CronSpec with offset as datetime.timezone, the validated instance contains string representation of the offset, which is not valid:
>>> CronSpec.model_validate(CronSpec(offset=datetime.datetime.now().astimezone().tzinfo.utcoffset(None)).model_dump(mode="json"))
CronSpec(minutes='*', hours='*', days='*', months='*', weekdays='*', offset='PT2H')
>>> datetime.datetime.now().astimezone().tzinfo.utcoffset(None)
datetime.timedelta(seconds=7200)
Kicking the tasks uses .model_dump(mode="json"), which is what breaks the timezone-typed value.
Relevant log output
Broker initialization code
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
s3rius commentedon Apr 10, 2026
It seems like a pydantic bug, actually. I'd not expect it to be serialized to such a weird value, actually. I'm not even sure what
PT{n}Hmeans.But I agree that actually it's quite unexpected.
Here's a pydantic issue:
pydantic/pydantic#7095