Skip to content

Automate browser based workflows with AI

fix bug SKY-7319 - when the conditional block doesn't have any block inside, the workflow fails the DAG check (#4300)

Shuchang Zheng05727466089c
diff --git a/skyvern/forge/sdk/workflow/service.py b/skyvern/forge/sdk/workflow/service.py
index c2b865b0d..2319d9687 100644
--- a/skyvern/forge/sdk/workflow/service.py
+++ b/skyvern/forge/sdk/workflow/service.py
@@ -1349,8 +1349,11 @@ class WorkflowService:
return
if target not in label_to_block:
raise InvalidWorkflowDefinition(f"Block {source} references unknown next_block_label {target}")
- adjacency[source].add(target)
- incoming[target] += 1
+ # Only increment incoming count if this is a new edge
+ # (multiple branches of a conditional block may point to the same target)
+ if target not in adjacency[source]:
+ adjacency[source].add(target)
+ incoming[target] += 1
for label, block in label_to_block.items():
if isinstance(block, ConditionalBlock):