You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "aeroyorch (via GitHub)" <gi...@apache.org> on 2026/08/31 15:57:48 UTC

[I] "Mark failed" returns 500 when a run has task instances for a task no longer in the DAG [airflow]

aeroyorch opened a new issue, #72338:
URL: https://github.com/apache/airflow/issues/72338

   ### Under which category would you file this issue?
   
   Airflow Core
   
   ### Apache Airflow version
   
   3.2.2
   
   ### What happened and how to reproduce it?
   
   After a few tasks were removed from a DAG, "Mark failed" on an older run returned HTTP 500:
   
   ```
   File ".../api/common/mark_tasks.py", line 344, in set_dag_run_state_to_failed
       pending_normal_tis = [ti for ti in pending_tis if not dag.task_dict[ti.task_id].is_teardown]
   KeyError: '<task removed in a later DAG version>'
   ```
   
   `pending_tis` is queried without restricting to the DAG's task ids, so it picks up TI rows for
   tasks the new version no longer has, and the `task_dict` lookup blows up. `running_tis`, built a few
   lines above, does apply that filter.
   
   The asymmetry is still there on `main`, where the code has since been refactored into
   `_set_dag_run_terminal_state`: `running_tis` has `TaskInstance.task_id.in_(task_ids)`,
   `pending_tis` does not, and the unguarded lookup is at line 300. So it survived that refactor.
   
   ### What you think should happen instead?
   
   The two queries should be consistent, and a leftover task instance should be ignored rather than raise.
   The scheduler already copes with this: once a run starts, `verify_integrity` marks such rows `removed`.
   
   ### 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?
   
   **Suggested fix**
   
   Add `TaskInstance.task_id.in_(task_ids)` to the `pending_tis` query, mirroring `running_tis`.
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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: commits-unsubscribe@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] "Mark failed" returns 500 when a run has task instances for a task no longer in the DAG [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun closed issue #72338: "Mark failed" returns 500 when a run has task instances for a task no longer in the DAG
URL: https://github.com/apache/airflow/issues/72338


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] "Mark failed" returns 500 when a run has task instances for a task no longer in the DAG [airflow]

Posted by "KHARSHAVARDHAN-eng (via GitHub)" <gi...@apache.org>.
KHARSHAVARDHAN-eng commented on issue #72338:
URL: https://github.com/apache/airflow/issues/72338#issuecomment-5482925739

   Hi! @aeroyorch ...I’d be interested in helping investigate and add a regression test for this issue. I’ll first take a closer look at the existing implementation and contribution guidelines to make sure the fix aligns with the project’s expectations...


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org