From 9c2943183e30b17deac5b08b19147ae48373b01b Mon Sep 17 00:00:00 2001 From: -LAN- Date: Thu, 4 Sep 2025 20:17:28 +0800 Subject: [PATCH] test: fix code node Signed-off-by: -LAN- --- api/core/workflow/nodes/code/code_node.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/core/workflow/nodes/code/code_node.py b/api/core/workflow/nodes/code/code_node.py index 04c73093a2..bd713e49ea 100644 --- a/api/core/workflow/nodes/code/code_node.py +++ b/api/core/workflow/nodes/code/code_node.py @@ -255,7 +255,13 @@ class CodeNode(Node): ) elif output_config.type == SegmentType.NUMBER: # check if number available - checked = self._check_number(value=result[output_name], variable=f"{prefix}{dot}{output_name}") + value = result.get(output_name) + if not isinstance(value, (int, float, None)): + raise OutputValidationError( + f"Output {prefix}{dot}{output_name} is not a number," + f" got {type(result.get(output_name))} instead." + ) + checked = self._check_number(value=value, variable=f"{prefix}{dot}{output_name}") # If the output is a boolean and the output schema specifies a NUMBER type, # convert the boolean value to an integer. #