Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
optimize: code node has a bad error message (#3949)
Yeuolye7b4d024eef3
diff --git a/api/core/workflow/nodes/code/code_node.py b/api/core/workflow/nodes/code/code_node.pyindex e9ff571844b..2c1529f492c 100644--- a/api/core/workflow/nodes/code/code_node.py+++ b/api/core/workflow/nodes/code/code_node.py@@ -141,10 +141,10 @@ class CodeNode(BaseNode)::return:"""if not isinstance(value, str):- raise ValueError(f"{variable} in output form must be a string")+ raise ValueError(f"Output variable `{variable}` must be a string")if len(value) > MAX_STRING_LENGTH:- raise ValueError(f'{variable} in output form must be less than {MAX_STRING_LENGTH} characters')+ raise ValueError(f'The length of output variable `{variable}` must be less than {MAX_STRING_LENGTH} characters')return value.replace('\x00', '')@@ -156,15 +156,15 @@ class CodeNode(BaseNode)::return:"""if not isinstance(value, int | float):- raise ValueError(f"{variable} in output form must be a number")+ raise ValueError(f"Output variable `{variable}` must be a number")if value > MAX_NUMBER or value < MIN_NUMBER:- raise ValueError(f'{variable} in input form is out of range.')+ raise ValueError(f'Output variable `{variable}` is out of range, it must be between {MIN_NUMBER} and {MAX_NUMBER}.')if isinstance(value, float):# raise error if precision is too highif len(str(value).split('.')[1]) > MAX_PRECISION:- raise ValueError(f'{variable} in output form has too high precision.')+ raise ValueError(f'Output variable `{variable}` has too high precision, it must be less than {MAX_PRECISION} digits.')return value@@ -271,7 +271,7 @@ class CodeNode(BaseNode):if len(result[output_name]) > MAX_NUMBER_ARRAY_LENGTH:raise ValueError(- f'{prefix}{dot}{output_name} in output form must be less than {MAX_NUMBER_ARRAY_LENGTH} characters.'+ f'The length of output variable `{prefix}{dot}{output_name}` must be less than {MAX_NUMBER_ARRAY_LENGTH} elements.')transformed_result[output_name] = [@@ -290,7 +290,7 @@ class CodeNode(BaseNode):if len(result[output_name]) > MAX_STRING_ARRAY_LENGTH:raise ValueError(- f'{prefix}{dot}{output_name} in output form must be less than {MAX_STRING_ARRAY_LENGTH} characters.'+ f'The length of output variable `{prefix}{dot}{output_name}` must be less than {MAX_STRING_ARRAY_LENGTH} elements.')transformed_result[output_name] = [@@ -309,7 +309,7 @@ class CodeNode(BaseNode):if len(result[output_name]) > MAX_OBJECT_ARRAY_LENGTH:raise ValueError(- f'{prefix}{dot}{output_name} in output form must be less than {MAX_OBJECT_ARRAY_LENGTH} characters.'+ f'The length of output variable `{prefix}{dot}{output_name}` must be less than {MAX_OBJECT_ARRAY_LENGTH} elements.')for i, value in enumerate(result[output_name]):diff --git a/api/tests/integration_tests/workflow/nodes/test_code.py b/api/tests/integration_tests/workflow/nodes/test_code.pyindex 9755cc3e2fd..c41d51caf76 100644--- a/api/tests/integration_tests/workflow/nodes/test_code.py+++ b/api/tests/integration_tests/workflow/nodes/test_code.py@@ -114,7 +114,7 @@ def test_execute_code_output_validator(setup_code_executor_mock):result = node.run(pool)assert result.status == WorkflowNodeExecutionStatus.FAILED- assert result.error == 'result in output form must be a string'+ assert result.error == 'Output variable `result` must be a string'def test_execute_code_output_validator_depth():code = '''