Reject cyclic TaskGroup dependencies during Dag parsing - #73087
Open
dheerajturaga wants to merge 3 commits into
Open
dheerajturaga wants to merge 3 commits into
dheerajturaga wants to merge 3 commits into
Conversation
TaskGroup dependency projections must remain acyclic because downstream consumers require an unambiguous group ordering.
dheerajturaga
requested review from
amoghrajesh,
ashb and
kaxil
as code owners
September 13, 2026 15:24
ashb
reviewed
Sep 14, 2026
…gment Review feedback on the parse-time TaskGroup cycle check: the doc's example claimed any cross-group task pairing triggers rejection, but the check only projects edges landing on a group's root tasks, so it understated what is and isn't caught. Reworded with an accurate example, and added the newsfragment the check's user-facing behavior change was missing, noting that apache#69933 is what turned a pre-existing cyclic-TaskGroup Dag from a silent rendering quirk into an unhandled Grid/Graph error, which is what this PR now catches earlier at parse time instead.
1 task
Member
Author
|
@ashb , If you are happy with this can we merge? looking to merge in time for 3.3.2 |
Member
Author
|
@vatsrahul1001, Any chance to get this in 3.3.2 ? |
kaxil
reviewed
Sep 14, 2026
Review feedback on the parse-time TaskGroup cycle check: the exception only named the containing TaskGroup, which collapses to the uninformative <root> for a cycle between top-level siblings and gives no hint which nodes to fix on a Dag with many groups. The sweep and pass-numbering sort passes already know which nodes never got processed, so surface those ids on the exception and include them in the message. Also documented and tested a second cycle shape the docs missed: a task with no upstream inside its own TaskGroup counts as a root of that group, so an external task can bridge two of a group's own tasks and close a cycle without a second TaskGroup in sight -- something that reads like an ordinary Dag until it fails to parse.
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.
Task graphs can be acyclic while cross-group edges create a cycle when sibling TaskGroups are treated as units. Downstream consumers require an unambiguous group ordering, so this rejects the configuration during Dag parsing instead of allowing it to fail later in Grid or Graph endpoints.
The check covers root and nested TaskGroup scopes, reports the offending scope, documents the restriction, and adds Task SDK and DagBag regression tests.
Before this PR, a Dag with cyclic TaskGroup dependencies could parse and run its tasks normally. #69933 fixed the group-level topological sort used by Grid and Graph to actually detect group-to-group and cross-group edges — it previously ignored them and rendered an arbitrary, incorrect order instead of failing. That turned a pre-existing cycle in a Dag's TaskGroups into an unhandled error from the Grid/Graph API endpoints rather than a rendering quirk. This PR moves that failure to Dag parsing time instead, where it raises a clear import error naming the offending TaskGroup.
This supersedes #72822
Was generative AI tooling used to co-author this PR?
Generated-by: Codex (GPT-5) and Claude Code (Sonnet 5) following the guidelines