iflytek/astron-agent · error · CustomException
CODE_EXECUTION_ERROR
CODE_EXECUTION_ERROR
Error message
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. What it means
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.
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.
Example fix
// before (.env) CODE_EXEC_TYPE=local // after (.env) CODE_EXEC_TYPE=e2b E2B_API_KEY=<your-key>
Defensive patterns
Strategy: validation
Validate before calling
import os
exec_type = os.getenv("CODE_EXEC_TYPE", "").strip().lower()
ISOLATED = {"e2b"} # per ISOLATED_CODE_EXECUTOR_TYPES
if exec_type not in ISOLATED:
raise ValueError(f"CODE_EXEC_TYPE must be one of {ISOLATED}, got '{exec_type}'") Type guard
def is_isolated_executor(v: str) -> bool:
return v.strip().lower() in ISOLATED_CODE_EXECUTOR_TYPES Try / catch
try:
result = code_node.execute_code(...)
except CustomException as e:
if e.err_code == CodeEnum.CODE_EXECUTION_ERROR:
alert("sandbox executor not configured: set CODE_EXEC_TYPE and sandbox credentials")
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- 21600
- MODEL_URL_ILLEGAL_FAILED
- Sandbox runtime configuration is unavailable
- Outbound hostname is blocked
- Invalid task creation URL
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/7ccd9a696deeaba9.
Report an issue: GitHub.
Appendix: source
Thrown at core/workflow/engine/nodes/code/code_node.py:185
# If the result is not a valid JSON string, return the result as a string
try:
return json.loads(result_str)
except Exception as e:
span_context.record_exception(e)
return {
self.output_identifier[0]: result_str,
}
@staticmethod
def _resolve_executor_type(sandbox_config: dict[str, Any] | None) -> str:
if sandbox_config is not None:
return "e2b"
executor_type = (
os.getenv("CODE_EXEC_TYPE", DEFAULT_CODE_EXECUTOR_TYPE).strip().lower()
)
if executor_type not in ISOLATED_CODE_EXECUTOR_TYPES:
raise CustomException(
CodeEnum.CODE_EXECUTION_ERROR,
err_msg=ISOLATED_CODE_EXECUTOR_REQUIRED_ERROR,
)
return executor_type
def _runtime_sandbox_config(self, span_context: Span) -> dict[str, Any] | None:
if self.sandbox is None or not self.sandbox.enabled:
return None
data = self.sandbox.model_dump()
data["uid"] = data.get("uid") or self.uid
data["node_id"] = data.get("node_id") or self.node_id
data["run_id"] = data.get("run_id") or getattr(span_context, "sid", "")
return data
def _check_and_set_variable_pool(
self, variable_pool: VariablePool, code_result_dict: dict, span: Span
) -> dict:
"""View on GitHub (pinned to 5e758547a8)