Only track conditionless edges in the conditionless-edge dedup set#507
Open
PratikDhanave wants to merge 5 commits into
Open
Only track conditionless edges in the conditionless-edge dedup set#507PratikDhanave wants to merge 5 commits into
PratikDhanave wants to merge 5 commits into
Conversation
Builder.AddDirectEdge appended every connection to conditionlessConnections, including conditional edges, but the duplicate check only fires for condition==nil and treats any entry as a pre-existing conditionless edge. So a conditional edge added first on a source->target pair made a subsequent legitimate conditionless edge on the same pair fail the dedup check with "an edge ... already exists without a condition" (or, via AddChain's idempotent path, be silently dropped). Guard the append with condition==nil so only conditionless edges populate the dedup set, matching the field's name and purpose. Adds tests for both the error path and the idempotent-drop path.
There was a problem hiding this comment.
Pull request overview
Fixes a bug in workflow.Builder.AddDirectEdge where conditional edges were incorrectly recorded in the conditionless-edge dedup tracking set, causing subsequent legitimate conditionless edges on the same source→target pair to be rejected (or silently dropped on idempotent paths like AddChain).
Changes:
- Only append to
wb.conditionlessConnectionswhencondition == nil, aligning the data structure with its intended purpose. - Add regression tests covering “conditional then conditionless” and the idempotent conditionless-edge path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| workflow/builder.go | Fixes conditionless-edge dedup bookkeeping so conditional edges don’t poison the conditionless dedup set. |
| workflow/builder_conditional_edge_test.go | Adds regression tests for conditional-vs-conditionless edge interactions and idempotent insertion behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Strengthen the idempotent test to inspect the built workflow's edges and confirm both a conditional and a conditionless edge from start exist, rather than only checking that Build succeeded (which held even when the edge was silently dropped).
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
Builder.AddDirectEdgeappends every connection towb.conditionlessConnections(builder.go), including conditional edges, but the duplicate check fires only whencondition == niland treats any entry in that list as a pre-existing conditionless edge. So a conditional edge added first on asource→targetpair poisons the dedup set: a subsequent legitimate conditionless edge on the same pair is wrongly rejected.Concrete trigger:
even though no conditionless edge exists. Via
AddChain(which callsAddDirectEdgewithidempotent=true), the same poisoning instead silently drops the chain edge (the dedup returns early without adding it).Fix
Guard the append with
condition == nil, so only conditionless edges populate the conditionless-edge dedup set — matching the field's name and sole purpose (it is read only by that dedup check).Public API
No exported symbols change.
Tests
TestBuilder_ConditionalEdgeDoesNotBlockConditionlessEdge— conditional then conditionless edge on the same pair now builds without error (fails before this change with the misleading duplicate error).TestBuilder_ConditionalEdgeDoesNotDropIdempotentConditionlessEdge— the idempotent path doesn't silently drop the conditionless edge.go test ./workflowpasses; gofmt clean.