Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(iteration): handle empty iterator gracefully (#9565)

-LAN-5459d812e7bb
diff --git a/api/core/workflow/nodes/iteration/iteration_node.py b/api/core/workflow/nodes/iteration/iteration_node.py
index b28ae0a85cf..7503c13ce81 100644
--- a/api/core/workflow/nodes/iteration/iteration_node.py
+++ b/api/core/workflow/nodes/iteration/iteration_node.py
@@ -46,6 +46,15 @@ class IterationNode(BaseNode[IterationNodeData]):
if not iterator_list_segment:
raise ValueError(f"Iterator variable {self.node_data.iterator_selector} not found")
+ if len(iterator_list_segment.value) == 0:
+ yield RunCompletedEvent(
+ run_result=NodeRunResult(
+ status=WorkflowNodeExecutionStatus.SUCCEEDED,
+ outputs={"output": []},
+ )
+ )
+ return
+
iterator_list_value = iterator_list_segment.to_object()
if not isinstance(iterator_list_value, list):