hkc-8010 opened a new issue, #70368:
URL: https://github.com/apache/airflow/issues/70368

   ### 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
   
   1. Define a DAG with a deadline referencing 
`DeadlineReference.DAGRUN_QUEUED_AT`.
   2. Let a run queue so a `Deadline` row is created.
   3. 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 `deadline` parameter from the DAG.
   
   ### Are you willing to submit a PR?
   
   Yes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to