From bf31a3efbc2d8e1ed8f9b0942e0f6ac29b778609 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Fri, 8 Nov 2024 19:48:05 +0800 Subject: [PATCH] feat(workflow-nodes): handle missing variables without failure (#10471) --- api/core/workflow/nodes/code/code_node.py | 8 +------- .../nodes/template_transform/template_transform_node.py | 7 +------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/api/core/workflow/nodes/code/code_node.py b/api/core/workflow/nodes/code/code_node.py index de70af58dd..ce283e38ec 100644 --- a/api/core/workflow/nodes/code/code_node.py +++ b/api/core/workflow/nodes/code/code_node.py @@ -49,13 +49,7 @@ class CodeNode(BaseNode[CodeNodeData]): for variable_selector in self.node_data.variables: variable_name = variable_selector.variable variable = self.graph_runtime_state.variable_pool.get(variable_selector.value_selector) - if variable is None: - return NodeRunResult( - status=WorkflowNodeExecutionStatus.FAILED, - inputs=variables, - error=f"Variable `{variable_selector.value_selector}` not found", - ) - variables[variable_name] = variable.to_object() + variables[variable_name] = variable.to_object() if variable else None # Run code try: result = CodeExecutor.execute_workflow_code_template( diff --git a/api/core/workflow/nodes/template_transform/template_transform_node.py b/api/core/workflow/nodes/template_transform/template_transform_node.py index 0ee66784c5..22a1b21888 100644 --- a/api/core/workflow/nodes/template_transform/template_transform_node.py +++ b/api/core/workflow/nodes/template_transform/template_transform_node.py @@ -34,12 +34,7 @@ class TemplateTransformNode(BaseNode[TemplateTransformNodeData]): for variable_selector in self.node_data.variables: variable_name = variable_selector.variable value = self.graph_runtime_state.variable_pool.get(variable_selector.value_selector) - if value is None: - return NodeRunResult( - status=WorkflowNodeExecutionStatus.FAILED, - error=f"Variable {variable_name} not found in variable pool", - ) - variables[variable_name] = value.to_object() + variables[variable_name] = value.to_object() if value else None # Run code try: result = CodeExecutor.execute_workflow_code_template(