iflytek/astron-agent · error · CustomExceptionCD
CODE_EXECUTION_ERROR
CODE_EXECUTION_ERROR
Error message
self._remove_traceback_stdin_line(resp_message)
What it means
CODE_EXECUTION_ERROR raised when the iFly v2 code service returns type == 'exec_code_failed'. The err_msg is the service's response message passed through _remove_traceback_stdin_line, which strips the noisy stdin line from the traceback so the message reflects the actual exception in the user's code.
Solutions
- Read the err_msg traceback in the workflow run detail; it shows the exact line and exception in the user code.
- Fix the bug in the code-node script (missing import, wrong variable name, unhandled None/empty input).
- Guard inputs from upstream nodes (check for None/empty before indexing) since node failures can feed incomplete data.
- Verify required packages exist in the sandbox image or vendor/declare the dependency.
Example fix
# before (user code)
result = data["total"] / count
// after
total = data.get("total", 0)
if not count:
result = 0
else:
result = total / count Defensive patterns
Strategy: try-catch
Validate before calling
# guard upstream inputs the code node will consume
assert isinstance(variable_pool.get("data"), dict) and variable_pool.get("data"), "upstream data missing before code node" Type guard
def is_safe_name(code: str) -> bool:
import ast
try:
ast.parse(code)
return True
except SyntaxError:
return False Try / catch
try:
output = await executor.execute(...)
except CustomExceptionCD as e:
if e.err_code == CodeEnum.CODE_EXECUTION_ERROR.code:
logger.error("user code failed: %s", e.err_msg) # err_msg carries cleaned traceback
output = error_placeholder Prevention
- Test code-node scripts with empty/None upstream outputs before publishing
- Use .get() with defaults instead of direct key access on upstream data
- Verify imports exist in the sandbox image
When it happens
Trigger: The user code inside a code node raised an unhandled exception (NameError, KeyError, ImportError, syntax error, division by zero, etc.) and the sandbox reported exec_code_failed with the Python traceback as the message.
Common situations: Typos or missing imports in code-node scripts; assuming an upstream variable exists when the producing node failed or renamed an output; dependency unavailable inside the sandbox; calling code with wrong variable types from the workflow.
Related errors
- ENG_PROTOCOL_VALIDATE_ERROR
- Failed to convert literal value
- VARIABLE_POOL_SET_PARAMETER_ERROR
- VARIABLE_POOL_GET_PARAMETER_ERROR
- get variable error
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/f3cb08d750e0ea48.
Report an issue: GitHub.
Appendix: source
Thrown at core/workflow/engine/nodes/code/executor/ifly/ifly_executor_v2.py:143
Handle error response and raise appropriate exception.
:param resp_json: Response json dictionary
:param span: Tracing span for logging
:raises CustomExceptionCD: Based on error type
"""
err_type = resp_json.get("type", "")
resp_message = resp_json.get("message", "")
span.add_error_event(f"err_type: {err_type}")
span.add_error_event(f"response message: {resp_message}")
if err_type == "exec_code_timeout":
raise CustomExceptionCD(
err_code=CodeEnum.CODE_EXECUTION_TIMEOUT_ERROR.code,
err_msg="Code execution timeout",
)
elif err_type == "exec_code_failed":
raise CustomExceptionCD(
err_code=CodeEnum.CODE_EXECUTION_ERROR.code,
err_msg=self._remove_traceback_stdin_line(resp_message),
)
else:
raise CustomExceptionCD(
err_code=CodeEnum.CODE_EXECUTION_ERROR.code,
err_msg="Code execution failed",
)
def _remove_traceback_stdin_line(self, traceback_str: str) -> str:
"""
Remove traceback line with V2-specific preprocessing.
Extends parent method by first extracting error message after
'exec code error:' prefix before removing stdin traceback line.
:param traceback_str: String containing traceback information
:return: String with the specified traceback line removedView on GitHub (pinned to 5e758547a8)