{"record":{"id":"6cd0fccefe369751","repo":"infiniflow/ragflow","slug":"failed-to-create-sandbox-workspace-result-stderr","errorCode":null,"errorMessage":"Failed to create sandbox workspace: {result.stderr_text or 'unknown error'}","messagePattern":"Failed to create sandbox workspace: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/sandbox/providers/tenki.py","lineNumber":165,"sourceCode":"            raise RuntimeError(f\"Tenki quota exceeded: {exc}\") from exc\n        except errors.RateLimitedError as exc:\n            raise RuntimeError(f\"Tenki rate limited, please retry: {exc}\") from exc\n        except errors.UnauthorizedError as exc:\n            raise SandboxProviderConfigError(\"Tenki authentication failed: check the API key.\") from exc\n        except Exception as exc:\n            # Satisfy the base contract: any other SDK failure becomes RuntimeError.\n            raise RuntimeError(f\"Failed to create Tenki sandbox: {exc}\") from exc\n\n        remote_work_dir = posixpath.join(SANDBOX_HOME, f\"ragflow-codeexec-{uuid.uuid4().hex}\")\n        try:\n            result = sandbox.exec(\n                \"mkdir\",\n                \"-p\",\n                posixpath.join(remote_work_dir, \"artifacts\"),\n                timeout=min(self.timeout, 10),\n            )\n            if result.exit_code != 0:\n                raise RuntimeError(f\"Failed to create sandbox workspace: {result.stderr_text or 'unknown error'}\")\n        except Exception:\n            self._safe_terminate(sandbox)\n            raise\n\n        instance_id = str(uuid.uuid4())\n        self._instances[instance_id] = {\n            \"sandbox\": sandbox,\n            \"remote_work_dir\": remote_work_dir,\n            \"language\": language,\n        }\n        logger.info(\"Tenki sandbox created (instance=%s, session=%s)\", instance_id, sandbox.id)\n\n        return SandboxInstance(\n            instance_id=instance_id,\n            provider=\"tenki\",\n            status=\"running\",\n            metadata={\"language\": language, \"remote_work_dir\": remote_work_dir, \"sandbox_id\": sandbox.id},\n        )","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/tenki.py#L147-L183","documentation":"Raised after the sandbox is created but the bootstrap 'mkdir -p <work_dir>/artifacts' command inside it exits non-zero. The remote workspace under /home/tenki could not be created, so the sandbox is terminated via _safe_terminate() and the create_instance() call fails.","triggerScenarios":"A custom image where /home/tenki is missing or not writable by the unprivileged 'tenki' user, a read-only or full filesystem in the microVM, or the mkdir being killed by the min(timeout, 10)s deadline returning a failure exit code.","commonSituations":"Swapping the default image for one with a different user/home layout; disk_size_gb set so small the filesystem cannot hold the workspace; custom images without a 'tenki' user account.","solutions":["Use the default image or ensure the custom image has a writable /home/tenki for user 'tenki'.","Increase disk_size_gb if the message indicates ENOSPC; check result.stderr_text in the exception message for the exact mkdir error.","Re-run create_instance() — transient microVM bootstrap failures are occasionally resolved by a fresh sandbox."],"exampleFix":"# before\nconfig = {\"api_key\": key, \"image\": \"custom-no-tenki-user:1.0\"}\n\n# after\nconfig = {\"api_key\": key}  # default image with writable /home/tenki","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    instance = provider.create_instance(template)\nexcept RuntimeError as exc:\n    if \"Failed to create sandbox workspace\" in str(exc):\n        # sandbox was already terminated by the provider; safe to retry once\n        instance = provider.create_instance(template)\n    else:\n        raise","preventionTips":["Use the default image or verify custom images have a writable /home/tenki for user 'tenki'.","Set disk_size_gb comfortably above workspace needs (or leave 0 for default).","Read the stderr_text embedded in the message — it carries mkdir's errno."],"tags":["sandbox","image","filesystem","tenki"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}