fix(graph): validate convergence targets in addParallelConditionalEdges#4455
Open
YuqiGuo105 wants to merge 1 commit intoalibaba:mainfrom
Open
Conversation
…alEdges (alibaba#4411) When using addParallelConditionalEdges, if different route branches' nodes have edges pointing to different convergence targets, findParallelNodeTargets() returns a Set with multiple elements. Previously, iterator().next() on a HashSet would silently pick one non-deterministically, causing the ConditionalParallelNode to route to an unpredictable next node. This fix adds compile-time validation: when parallelNodeTargets.size() > 1, a GraphStateException is thrown with a clear error message listing the conflicting convergence targets. Changes: - CompiledGraph.java: Add size > 1 check before iterator().next() - Errors.java: Add inconsistentConvergenceTargetsOnConditionalParallelEdge error - StateGraphTest.java: Add test for inconsistent convergence targets Closes alibaba#4411
1 task
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
Fixes #4411
When using
addParallelConditionalEdges(), if different route branches' mapped nodes have edges pointing to different convergence targets,findParallelNodeTargets()returns aSetwith multiple elements.HashSet.iterator().next()then silently picks one non-deterministically, causing theConditionalParallelNodeto route to an unpredictable next node after parallel execution.Root Cause
In
CompiledGraphconstructor, when processing conditional parallel edges:findParallelNodeTargets()collects each route branch node's edge target into aSet<String>parallelNodeTargets.iterator().next()picks whichever element HashSet happens to return first - this is non-deterministicFix
Added compile-time validation in
CompiledGraph: whenparallelNodeTargets.size() > 1, throwGraphStateExceptionwith a clear error message listing the conflicting convergence targets, rather than silently picking a random one.This approach aligns with the issue reporter's suggestion: 'findParallelNodeTargets returns multiple targets should throw GraphStateException'
Changes
CompiledGraph.javasize() > 1validation check beforeiterator().next()Errors.javainconsistentConvergenceTargetsOnConditionalParallelEdgeerror constantStateGraphTest.javaTest
All 4
testAddParallelConditionalEdges*tests pass (BUILD SUCCESS).