{"record":{"id":"7ccd9a696deeaba9","repo":"iflytek/astron-agent","slug":"code-execution-error","errorCode":"CODE_EXECUTION_ERROR","errorMessage":"No isolated code executor is configured. Enable the E2B sandbox, keep the built-in {DEFAULT_CODE_EXECUTOR_TYPE} executor enabled, or configure CODE_EXEC_TYPE with another isolated executor. In-process local execution is disabled.","messagePattern":"No isolated code executor is configured\\. Enable the E2B sandbox, keep the built-in (.+?) executor enabled, or configure CODE_EXEC_TYPE with another isolated executor\\. In-process local execution is disabled\\.","errorType":"error_code","errorClass":"CustomException","httpStatus":null,"severity":"error","filePath":"core/workflow/engine/nodes/code/code_node.py","lineNumber":185,"sourceCode":"        # If the result is not a valid JSON string, return the result as a string\n        try:\n            return json.loads(result_str)\n        except Exception as e:\n            span_context.record_exception(e)\n            return {\n                self.output_identifier[0]: result_str,\n            }\n\n    @staticmethod\n    def _resolve_executor_type(sandbox_config: dict[str, Any] | None) -> str:\n        if sandbox_config is not None:\n            return \"e2b\"\n\n        executor_type = (\n            os.getenv(\"CODE_EXEC_TYPE\", DEFAULT_CODE_EXECUTOR_TYPE).strip().lower()\n        )\n        if executor_type not in ISOLATED_CODE_EXECUTOR_TYPES:\n            raise CustomException(\n                CodeEnum.CODE_EXECUTION_ERROR,\n                err_msg=ISOLATED_CODE_EXECUTOR_REQUIRED_ERROR,\n            )\n        return executor_type\n\n    def _runtime_sandbox_config(self, span_context: Span) -> dict[str, Any] | None:\n        if self.sandbox is None or not self.sandbox.enabled:\n            return None\n        data = self.sandbox.model_dump()\n        data[\"uid\"] = data.get(\"uid\") or self.uid\n        data[\"node_id\"] = data.get(\"node_id\") or self.node_id\n        data[\"run_id\"] = data.get(\"run_id\") or getattr(span_context, \"sid\", \"\")\n        return data\n\n    def _check_and_set_variable_pool(\n        self, variable_pool: VariablePool, code_result_dict: dict, span: Span\n    ) -> dict:\n        \"\"\"","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/engine/nodes/code/code_node.py#L167-L203","documentation":"The code node refuses to run user code without an isolated executor. _resolve_executor_type reads CODE_EXEC_TYPE (falling back to DEFAULT_CODE_EXECUTOR_TYPE) and raises CODE_EXECUTION_ERROR if the resolved value is not in ISOLATED_CODE_EXECUTOR_TYPES (e.g. e2b or other sandboxed executors). In-process local execution is deliberately disabled for security, so a missing or invalid configuration is a hard error.","triggerScenarios":"Executing a code node when: CODE_EXEC_TYPE is unset and the default is not an isolated type; CODE_EXEC_TYPE is set to 'local', 'disabled', an empty string, or any typo not in ISOLATED_CODE_EXECUTOR_TYPES; or the E2B sandbox is not enabled/configured.","commonSituations":"Fresh deployment where the E2B API key / sandbox config was never set; operator downgraded CODE_EXEC_TYPE to 'local' expecting it to work after a security change; typo like 'E2B ' with whitespace is handled by strip/lower but values like 'python-local' are not; environment variable set only in one deployment environment (dev vs prod).","solutions":["Set CODE_EXEC_TYPE to an isolated executor from ISOLATED_CODE_EXECUTOR_TYPES (e.g. `export CODE_EXEC_TYPE=e2b`).","Ensure the E2B sandbox is enabled: configure its API key/endpoint (E2B_* variables) per the deployment docs.","If relying on the default, confirm DEFAULT_CODE_EXECUTOR_TYPE itself is an isolated type in your build, or override it explicitly.","Remove any `CODE_EXEC_TYPE=local|disabled|\"\"` from env files/compose/helm values and redeploy.","Verify with a minimal workflow containing a code node that the executor resolves before running production flows."],"exampleFix":"// before (.env)\nCODE_EXEC_TYPE=local\n\n// after (.env)\nCODE_EXEC_TYPE=e2b\nE2B_API_KEY=<your-key>","handlingStrategy":"validation","validationCode":"import os\nexec_type = os.getenv(\"CODE_EXEC_TYPE\", \"\").strip().lower()\nISOLATED = {\"e2b\"}  # per ISOLATED_CODE_EXECUTOR_TYPES\nif exec_type not in ISOLATED:\n    raise ValueError(f\"CODE_EXEC_TYPE must be one of {ISOLATED}, got '{exec_type}'\")","typeGuard":"def is_isolated_executor(v: str) -> bool:\n    return v.strip().lower() in ISOLATED_CODE_EXECUTOR_TYPES","tryCatchPattern":"try:\n    result = code_node.execute_code(...)\nexcept CustomException as e:\n    if e.err_code == CodeEnum.CODE_EXECUTION_ERROR:\n        alert(\"sandbox executor not configured: set CODE_EXEC_TYPE and sandbox credentials\")\n    raise","preventionTips":["Always set CODE_EXEC_TYPE in every environment's env file","Provision E2B (or equivalent) credentials during deployment, not at first failure","Add a startup healthcheck that resolves the executor type","Never revert to local execution; treat it as a permanently disabled option"],"tags":["config","sandbox","code-execution","security","env-var"],"backgroundTag":"missing-env-var","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}