Skip to content

datetime.timedelta serde cannot deserialize integer payloads, crashing scheduler during DeadlineAlert DAG-run creation #72319

Closed

Description

@jgoedeke

Under which category would you file this issue?

Task SDK

Apache Airflow version

3.3.0

What happened and how to reproduce it?

The scheduler crashes while creating an asset-triggered DAG run for a DAG with a DeadlineAlert interval of timedelta(minutes=45).

The serialized DAG payload observed in the scheduler traceback contains:

{
    "__classname__": "datetime.timedelta",
    "__version__": 2,
    "__data__": 2700,
}

The SDK datetime deserializer only accepts str | float for datetime.timedelta:

if cls is datetime.timedelta and isinstance(data, str | float):
    return datetime.timedelta(seconds=float(data))

Since 2700 is an int, deserialization raises:

TypeError: unknown date/time format datetime.timedelta

The exception is unhandled in scheduler DAG-run creation and terminates the scheduler process.

Minimal reproduction

from datetime import timedelta

from airflow.sdk.serde import CLASSNAME, DATA, VERSION, deserialize

serialized_timedelta = {
    CLASSNAME: "datetime.timedelta",
    VERSION: 2,
    DATA: 2700,
}

assert deserialize(serialized_timedelta) == timedelta(minutes=45)

Actual result

TypeError: unknown date/time format datetime.timedelta

Expected result

timedelta(minutes=45)

Proposed fix

Accept integer second values alongside the already accepted string and float forms.

What you think should happen instead?

No response

Operating System

No response

Deployment

None

Apache Airflow Provider(s)

No response

Versions of Apache Airflow Providers

No response

Official Helm Chart version

Not Applicable

Kubernetes Version

No response

Helm Chart configuration

No response

Docker Image customizations

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added
    kind:bug
    needs-triage
    on Aug 31, 2026
  2. CaptainAni187 commented on Sep 8, 2026

    @CaptainAni187

    Reproduced on main and opened #72710 with the widening you suggested.

    I went looking for what actually emits the bare int and couldn't pin it down from inside the repo — serialize() writes total_seconds() as a float, BaseSerialization does the same, and a JSON round-trip keeps 2700.0 intact. So I've written the PR as a defensive widening rather than claiming to have traced your traceback. If you happen to know which producer the payload came through, that'd be useful to note on the PR.

    Either way the value is clearly reachable, and the datetime branch a few lines above already accepts int | float for the same kind of cross-producer reason, so accepting it one type down seems consistent.

    Test is parametrised over int/float/str — on main only the int case fails, which keeps it pinned to the actual broken path.

  3. added a commit that references this issue on Sep 22, 2026
    5aee0fb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:bugneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions