From b376f7aeec5deba1d8c3e501cad937f51cc8991c Mon Sep 17 00:00:00 2001 From: QuantumGhost Date: Thu, 29 May 2025 02:26:27 +0800 Subject: [PATCH] feat(api): include the loop variables in extracted variable mappings --- api/core/workflow/nodes/loop/loop_node.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/core/workflow/nodes/loop/loop_node.py b/api/core/workflow/nodes/loop/loop_node.py index 420a8e0fc3..088c003d3e 100644 --- a/api/core/workflow/nodes/loop/loop_node.py +++ b/api/core/workflow/nodes/loop/loop_node.py @@ -478,6 +478,13 @@ class LoopNode(BaseNode[LoopNodeData]): variable_mapping.update(sub_node_variable_mapping) + for loop_variable in node_data.loop_variables: + if loop_variable.value_type == "variable": + assert loop_variable.value is not None, "Loop variable value must be provided for variable type" + # add loop variable to variable mapping + selector = loop_variable.value + variable_mapping[f"{node_id}.{loop_variable.label}"] = selector + # remove variable out from loop variable_mapping = { key: value for key, value in variable_mapping.items() if value[0] not in loop_graph.node_ids