diff --git a/api/app/core/workflow/nodes/code/config.py b/api/app/core/workflow/nodes/code/config.py index 35b757e9..8af13f12 100644 --- a/api/app/core/workflow/nodes/code/config.py +++ b/api/app/core/workflow/nodes/code/config.py @@ -39,7 +39,7 @@ class CodeNodeConfig(BaseNodeConfig): description="output variables" ) - code_content: str = Field( + code: str = Field( default="", description="code content" ) diff --git a/api/app/core/workflow/nodes/code/node.py b/api/app/core/workflow/nodes/code/node.py index 3e15089b..5262a7e2 100644 --- a/api/app/core/workflow/nodes/code/node.py +++ b/api/app/core/workflow/nodes/code/node.py @@ -47,7 +47,7 @@ class CodeNode(BaseNode): result = {} for output in self.typed_config.output_variables: value = exec_result.get(output.name) - if not value: + if value is None: raise RuntimeError(f"Return value {output.name} does not exist") match output.type: case VariableType.STRING: @@ -104,7 +104,7 @@ class CodeNode(BaseNode): "x-api-key": 'redbear-sandbox' }, json={ - "language": "python3", + "language": self.typed_config.language, "code": base64.b64encode(final_script.encode("utf-8")).decode("utf-8"), "options": { "enable_network": True diff --git a/sandbox/app/services/python_service.py b/sandbox/app/services/python_service.py index 5700841d..210b2086 100644 --- a/sandbox/app/services/python_service.py +++ b/sandbox/app/services/python_service.py @@ -37,7 +37,7 @@ async def run_python_code(code: str, preload: str, options: RunnerOptions): if result.exit_code == -signal.SIGSYS: return error_response(31, "sandbox security policy violation") - if result.stderr: + if result.stderr and result.exit_code != 0: return error_response(500, result.stderr) return success_response(RunCodeResponse(