Clearing a DAG run/task instance with a DagRunQueuedAtDeadline fails with TypeError: unsupported type for timedelta seconds component: dict
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- data-engineering
Research direction
Start in airflow-core/src/airflow/models/taskinstance.py at _recalculate_dagrun_queued_at_deadlines(), called by clear_task_instances, and compare its interval handling with DagRun creation in serialization/definitions/dag.py and the model repr. Verify the clear path handles the migrated deadline interval correctly; done means clearing a DAG run or task instance succeeds and recalculates the queued-at deadline without the TypeError.
Written by the indexing model from the issue text.
Description
Apache Airflow version
3.3.0 and later
What happened
Clearing a failed DAG run or task instance returns HTTP 500 ("Internal Service Error") in the UI when the DAG defines a deadline that references the DAG run's queued_at time (DeadlineReference.DAGRUN_QUEUED_AT). The API server logs:
TypeError: unsupported type for timedelta seconds component: dict
What you think should happen instead
The clear should succeed, and the queued-at deadline should be recalculated against the new queued_at.
Root cause
In 3.3.0, migration 0117_3_3_0_change_deadline_interval_to_json.py (from #64751, which added VariableInterval support) changed the deadline_alert.interval column from FLOAT to JSON. Existing values were rewritten into the serde envelope, e.g. {"__classname__": "datetime.timedelta", "__version__": 2, "__data__": 3600.0}.
_recalculate_dagrun_queued_at_deadlines() in airflow-core/src/airflow/models/taskinstance.py (called from clear_task_instances) still reads the raw column and does timedelta(seconds=deadline_alert.interval), passing the JSON dict straight into timedelta. Every other consumer (DagRun creation in serialization/definitions/dag.py, the model __repr__) decodes the JSON first. Only the clear path was missed.
How to reproduce
- Define a DAG with a deadline referencing
DeadlineReference.DAGRUN_QUEUED_AT. - Let a run queue so a
Deadlinerow is created. - Clear the DAG run or one of its task instances.
The API server returns 500 with the TypeError above.
Workarounds
- Delete the task instance in the UI instead of clearing it.
- Temporarily remove the
deadlineparameter from the DAG.
Are you willing to submit a PR?
Yes.
- Dominant language
- Python
- Stars
- 46.9k
- Forks
- 17.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 480
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/airflow
-
kind:bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
area:providers good first issue kind:bug kind:documentation provider:google
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
kind:bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
area:core kind:bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:providers kind:bug provider:cncf-kubernetes
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100