{"record":{"id":"b6d5928fab27164c","repo":"infiniflow/ragflow","slug":"tenki-execution-failed-exc","errorCode":null,"errorMessage":"Tenki execution failed: {exc}","messagePattern":"Tenki execution failed: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/sandbox/providers/tenki.py","lineNumber":223,"sourceCode":"        script_path, argv = self._prepare_script(sandbox, remote_work_dir, normalized_lang, code, args_json)\n\n        requested_timeout = self.timeout if timeout is None else int(timeout)\n        if requested_timeout <= 0:\n            raise RuntimeError(f\"Execution timeout must be greater than 0 seconds, got {requested_timeout}.\")\n        exec_timeout = min(requested_timeout, self.timeout)\n\n        start_time = time.time()\n        try:\n            result = sandbox.exec(*argv, cwd=remote_work_dir, timeout=exec_timeout)\n        except (errors.CommandTimeoutError, errors.PrimitiveTimeoutError) as exc:\n            logger.warning(\"Tenki execution timed out (instance=%s, timeout=%ss)\", instance_id, exec_timeout)\n            raise TimeoutError(f\"Execution timed out after {exec_timeout} seconds\") from exc\n        except (errors.SessionTerminatedError, errors.SessionNotFoundError) as exc:\n            # The sandbox was reclaimed (e.g. max_lifetime) or lost mid-run;\n            # surface it as RuntimeError per the base contract, not an SDK type.\n            raise RuntimeError(f\"Tenki sandbox is no longer available: {exc}\") from exc\n        except Exception as exc:\n            raise RuntimeError(f\"Tenki execution failed: {exc}\") from exc\n        execution_time = time.time() - start_time\n\n        stdout = result.stdout_text\n        stderr = result.stderr_text\n        exit_code = int(result.exit_code)\n\n        self._validate_output_size(stdout, stderr)\n        stdout, structured_result = extract_structured_result(stdout)\n\n        return ExecutionResult(\n            stdout=stdout,\n            stderr=stderr,\n            exit_code=exit_code,\n            execution_time=execution_time,\n            metadata={\n                \"instance_id\": instance_id,\n                \"language\": normalized_lang,\n                \"script_path\": script_path,","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/tenki.py#L205-L241","documentation":"Catch-all RuntimeError for sandbox.exec() failures that are not timeout or session-loss errors — network drops to the Tenki API mid-exec, SDK protocol errors, or exec-level failures. The original SDK exception is preserved as __cause__.","triggerScenarios":"Transient network interruptions between the provider and Tenki while the script runs, SDK errors while streaming stdout/stderr, or the sandbox runtime failing to spawn the executable (e.g. python3/node missing in a custom image).","commonSituations":"Custom images without python3 or node on PATH (argv is [executable, script_path]); flaky egress from self-hosted RAGFlow to the Tenki API; SDK version drift between the tenki package and API.","solutions":["Check exc.__cause__ for the SDK's original error text — it distinguishes 'executable not found' from transport failures.","If transport-related, retry execute_code() on the same instance (the session may still be alive).","Verify the image provides python3 (python template) and node (javascript template) executables."],"exampleFix":"# before\nresult = provider.execute_code(instance_id, code)\n\n# after\ntry:\n    result = provider.execute_code(instance_id, code)\nexcept RuntimeError as exc:\n    logger.error(\"tenki exec failed: %s\", exc.__cause__)\n    raise","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = provider.execute_code(instance_id, code)\nexcept RuntimeError as exc:\n    if \"Tenki execution failed\" in str(exc):\n        cause = exc.__cause__\n        logger.error(\"exec error, cause=%r\", cause)\n        if is_transient(cause):  # e.g. transport error\n            return provider.execute_code(instance_id, code)\n    raise","preventionTips":["Log exc.__cause__ — it separates missing-interpreter from network problems.","Ensure custom images ship python3 and node on PATH.","Retry once on transport-looking causes; never blind-retry unknown failures."],"tags":["execution","sdk","network","tenki"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}