fix(sandbox): treat non-zero exit codes as errors instead of relying only on stderr
This commit is contained in:
@@ -39,7 +39,7 @@ class CodeNodeConfig(BaseNodeConfig):
|
||||
description="output variables"
|
||||
)
|
||||
|
||||
code_content: str = Field(
|
||||
code: str = Field(
|
||||
default="",
|
||||
description="code content"
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user