From db1aa687741a6fda96907a93b6ff7e3bbf6f0619 Mon Sep 17 00:00:00 2001 From: pierrejeambrun Date: Fri, 2 Oct 2026 11:23:33 +0200 Subject: [PATCH] Update the stale cycle-detection comment on SerializedTaskGroup.topological_sort DAG.check_cycle was the only guard this comment named, but a Lang-SDK Dag never runs it: it has no Python DAG object to call it on. The Dag processor now rejects a cyclic Lang-SDK Dag of its own accord, through DagSerialization.validate_serialized_dag, so the comment should name both guards rather than the one that does not cover every author. --- .../src/airflow/serialization/definitions/taskgroup.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/airflow-core/src/airflow/serialization/definitions/taskgroup.py b/airflow-core/src/airflow/serialization/definitions/taskgroup.py index b82e1c0b9335a..8e9fe75e6b274 100644 --- a/airflow-core/src/airflow/serialization/definitions/taskgroup.py +++ b/airflow-core/src/airflow/serialization/definitions/taskgroup.py @@ -237,9 +237,12 @@ def topological_sort( Sort children topologically — a task always comes after its upstream dependencies. See ``TaskGroup.topological_sort`` in task-sdk for the algorithm. Cycles are - treated as corrupt input: ``DAG.check_cycle`` rejects cyclic Dags before - serialization, so a cycle reaching this code indicates malformed serialized data, - and we raise ``ValueError`` rather than silently looping forever. + treated as corrupt input: a Python Dag's cycle is rejected by ``DAG.check_cycle`` + before serialization, and a Lang-SDK Dag's cycle is rejected by + ``DagSerialization.validate_serialized_dag`` when the Dag processor receives it + (both call the shared ``detect_cycle``). A cycle reaching this code indicates + malformed serialized data, and we raise ``ValueError`` rather than silently + looping forever. """ children = self.children if not children: