Repository navigation
Conversation
Eason09053360
requested review from
XD-DENG,
amoghrajesh and
ashb
as code owners
September 27, 2026 18:18
Airflow 3 allows Dag runs without a logical date, which the helper behind these two debugging commands never accounted for. An absent date widened both its collision lookup and its pre-test clear into match-everything queries, so testing a single task could delete a run the user had triggered from the UI, along with its task instances and their history. A command whose whole purpose is local debugging must not touch data it was never pointed at.
Eason09053360
force-pushed
the
fix-tasks-test-deleting-unrelated-dag-runs-v2
branch
from
September 28, 2026 04:29
a3c27b5 to
c0eda11
Compare
Contributor
|
Thanks for the fix. |
fat-catTW
approved these changes
Sep 30, 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.
Reopening #72656, which was closed by the one-time open PR limit sweep.
related: #72656
Why
airflow tasks testandDAG.test()can delete a Dag run the user triggered from theUI, along with its task instances.
Airflow 3 lets runs have no logical date — manual and asset-triggered runs store
NULL— but the helper behind both entry points still treats an absent date as"match anything":
get_or_create_dagrundeletes the run occupying the logical date it is about to use.The lookup uses
==, which SQLAlchemy renders asIS NULL, so a dateless test deletesan arbitrary dateless run — and
DagRun.task_instancescascades.DAG.test()first clears task instances viaclear_dags, passing the logical date asboth bounds.
Nonedrops both, leavingTaskInstance.dag_id == <dag_id>— every runof the Dag.
NULL dates cannot collide under the
(dag_id, logical_date)unique key, so bothoperations are skipped when the date is absent.
What
Both call sites guarded, one regression test each.
session.commit()becamesession.flush(): the line moves in this diff anyway, andairflow-coreforbids a callee committing a session it was handed.Repeated dateless
dag.test()calls now accumulate runs instead of each deleting thelast.
--logical-date <D>still replaces a real run sitting atD.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5) following the guidelines