From 203732de1d04a8796b17abdbd12e229c55030810 Mon Sep 17 00:00:00 2001 From: Eternity <1533512157@qq.com> Date: Fri, 3 Apr 2026 10:18:33 +0800 Subject: [PATCH] fix(code-node): prevent null errors by adding default value handling --- api/app/core/workflow/nodes/code/node.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/app/core/workflow/nodes/code/node.py b/api/app/core/workflow/nodes/code/node.py index d89b208b..69c660fe 100644 --- a/api/app/core/workflow/nodes/code/node.py +++ b/api/app/core/workflow/nodes/code/node.py @@ -13,7 +13,7 @@ from app.core.workflow.engine.state_manager import WorkflowState from app.core.workflow.engine.variable_pool import VariablePool from app.core.workflow.nodes import BaseNode from app.core.workflow.nodes.code.config import CodeNodeConfig -from app.core.workflow.variable.base_variable import VariableType +from app.core.workflow.variable.base_variable import VariableType, DEFAULT_VALUE logger = logging.getLogger(__name__) @@ -70,7 +70,8 @@ class CodeNode(BaseNode): for output in self.typed_config.output_variables: value = exec_result.get(output.name) if value is None: - raise RuntimeError(f"Return value {output.name} does not exist") + result[output.name] = DEFAULT_VALUE(output.type) + continue match output.type: case VariableType.STRING: if not isinstance(value, str):