Skip to content

Commit

Permalink
fix(iteration): handle empty iterator gracefully (#9565)
Browse files Browse the repository at this point in the history
  • Loading branch information
laipz8200 authored Oct 21, 2024
1 parent 831c222 commit 5459d81
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/core/workflow/nodes/iteration/iteration_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ def _run(self) -> Generator[NodeEvent | InNodeEvent, None, None]:
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):
Expand Down

0 comments on commit 5459d81

Please sign in to comment.