zylon-ai/private-gpt · error · CodeExecutionError

Execution failed: {result.error or 'Unknown error'}

Error message

Execution failed: {result.error or 'Unknown error'}

What it means

Raised by _process_execution_result when the remote sandbox reports success=False for the run. The sandbox transport returns a SandboxExecutionResult; a failed run carries result.error (stderr/exception from inside the sandbox), which is interpolated, defaulting to 'Unknown error' when the transport gives no detail. This differs from error 246: 246 wraps transport/pre-processing exceptions, 248 handles a completed-but-failed run.

Source

Thrown at private_gpt/components/tabular/pandasai_sandbox.py:434

                    plt.savefig(_buf, format='png', dpi=150, bbox_inches='tight')
                    _buf.seek(0)
                    _image_b64 = base64.b64encode(_buf.getvalue()).decode('utf-8')
                    _buf.close()
                    _execution_result['value'] = f"data:image/png;base64,{_image_b64}"

            print("EXECUTION_RESULT_START")
            print(json.dumps(_execution_result, cls=CustomEncoder))
            print("EXECUTION_RESULT_END")
        """
        )

        return code

    def _process_execution_result(
        self, result: SandboxExecutionResult
    ) -> dict[str, Any]:
        if not result.success:
            raise CodeExecutionError(
                f"Execution failed: {result.error or 'Unknown error'}"
            )

        try:
            lines = result.output.strip().split("\n")
            start_idx: int | None = None
            end_idx: int | None = None

            for i, line in enumerate(lines):
                if line.strip() == "EXECUTION_RESULT_START":
                    start_idx = i + 1
                elif line.strip() == "EXECUTION_RESULT_END":
                    end_idx = i
                    break

            if start_idx is not None and end_idx is not None:
                json_str = "\n".join(lines[start_idx:end_idx])
                json_obj: dict[str, Any] = json.loads(json_str)

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Inspect result.error content when present — it is the sandbox-side traceback.
  2. For 'Unknown error': check sandbox-side logs; a killed/OOM process produces no error text — raise memory limits or simplify the generated analysis.
  3. Retry once — transient sandbox kills usually succeed on regeneration.
  4. Reduce dataset size streamed into the sandbox if memory-bound.
Defensive patterns

Strategy: retry

Try / catch

from pandasai.exceptions import CodeExecutionError

try:
    payload = sandbox._process_execution_result(result)
except CodeExecutionError as e:
    if result.error:
        log_sandbox_traceback(result.error)  # actionable detail
        raise
    retry_analysis_once()  # 'Unknown error' often transient kill

Prevention

When it happens

Trigger: The generated code runs in the sandbox and the sandbox itself marks the run failed: uncaught Python exception in the generated code at the top level, process killed, or sandbox-internal failure. result.error empty while success=False yields 'Unknown error'.

Common situations: Generated code calls sys.exit or crashes the interpreter; OOM inside the sandbox; sandbox runtime version mismatch; empty error when the process is killed by signal (no traceback captured).

Related errors


AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15). Data as JSON: /api/errors/70eaad62edf36c99. Report an issue: GitHub.