Repository navigation
Fix mark-failed KeyError for removed-task TIs (#72338) - #72394
Merged
pierrejeambrun merged 1 commit intoSep 7, 2026
Merged
Conversation
deepujain
requested review from
ephraimbuddy,
jason810496,
pierrejeambrun and
rawwar
as code owners
September 1, 2026 20:52
deepujain
force-pushed
the
fix-72338-mark-failed-removed-task
branch
3 times, most recently
from
September 2, 2026 14:55
eb43467 to
89868ee
Compare
ephraimbuddy
approved these changes
Sep 2, 2026
deepujain
force-pushed
the
fix-72338-mark-failed-removed-task
branch
5 times, most recently
from
September 3, 2026 07:45
c4cb024 to
02bdd83
Compare
deepujain
force-pushed
the
fix-72338-mark-failed-removed-task
branch
from
September 4, 2026 15:58
02bdd83 to
84c7f26
Compare
Contributor
Backport successfully created: v3-3-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
pierrejeambrun
pushed a commit
that referenced
this pull request
Sep 7, 2026
…72394) (#72620) (cherry picked from commit ddc423b) Co-authored-by: Deepak Jain (DJ) <[email protected]>
regarmukesh3g
pushed a commit
to regarmukesh3g/airflow
that referenced
this pull request
Sep 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Marking a DAG run failed could raise
KeyErrorwhen the run still had task instance rows for tasks removed in a later DAG version. Thepending_tisquery did not filter to the current DAG's task ids, unlike therunning_tisquery, so lookups intodag.task_dictfailed on orphaned rows. This change filters pending task instances the same way running ones are filtered.Changes
airflow-core/src/airflow/api/common/mark_tasks.py-- addTaskInstance.task_id.in_(task_ids)to the pending task instance query in_set_dag_run_terminal_state.airflow-core/tests/unit/api/common/test_mark_tasks.py-- add regression test for mark-failed with a leftover TI for a removed task.Test plan
ruff checkandruff format --checkon changed filespytest airflow-core/tests/unit/api/common/test_mark_tasks.py::test_set_dag_run_state_to_failed_ignores_removed_task_tis(2 passed with existing test)Was generative AI tooling used to co-author this PR?
Generated-by: OpenAI Codex following the guidelines
Fixes #72338