{"record":{"id":"bca7f09f482d8b53","repo":"agentscope-ai/agentscope","slug":"bubblewrap-read-file-failed-exit-result-exit-cod","errorCode":null,"errorMessage":"Bubblewrap read_file failed (exit {result.exit_code}): {result.stderr.decode(errors='replace')}","messagePattern":"Bubblewrap read_file failed \\(exit (.+?)\\): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/agentscope/workspace/_bubblewrap/_bubblewrap_backend.py","lineNumber":276,"sourceCode":"                    'resolved=$(realpath -e -- \"$1\") || exit 66; '\n                    'case \"$resolved\" in '\n                    \"/workspace|/workspace/*|/tmp|/tmp/*) \"\n                    'cat -- \"$resolved\" ;; '\n                    \"*) exit 65 ;; \"\n                    \"esac\"\n                ),\n                \"sh\",\n                sandbox_path,\n            ],\n        )\n        if result.exit_code == 66:\n            raise FileNotFoundError(f\"not found in Bubblewrap sandbox: {path}\")\n        if result.exit_code == 65:\n            raise PermissionError(\n                f\"path escapes writable Bubblewrap mounts: {path}\",\n            )\n        if not result.ok():\n            raise RuntimeError(\n                \"Bubblewrap read_file failed \"\n                f\"(exit {result.exit_code}): \"\n                f\"{result.stderr.decode(errors='replace')}\",\n            )\n        return result.stdout\n\n    async def write_file(self, path: str, data: bytes) -> None:\n        \"\"\"Write raw bytes, refusing every symbolic-link final component.\"\"\"\n        await self._write_via_cat(path, data)\n\n    async def write_stream(\n        self,\n        path: str,\n        stream: AsyncIterator[bytes],\n    ) -> None:\n        \"\"\"Stream bytes into ``path``, chunk by chunk through ``cat``.\"\"\"\n        await self._write_via_cat(path, stream)\n","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/workspace/_bubblewrap/_bubblewrap_backend.py#L258-L294","documentation":"A catch-all RuntimeError from read_file when the sandboxed cat command fails with an unexpected exit code. The message embeds the exit code and the sandboxed command's stderr, which is the primary diagnostic.","triggerScenarios":"Any failure of the inner `sh -c cat` that is neither exit 66 (not found) nor 65 (outside writable mounts): e.g. permission bits on the file inside the sandbox, I/O errors, or bwrap itself failing to launch.","commonSituations":"Read-only or corrupted mounts inside the sandbox, a broken bwrap installation, or disk errors. Inspect result.stderr embedded in the message.","solutions":["Read the embedded stderr in the exception message to identify the underlying cause","Verify bwrap works standalone (bwrap --ro-bind / / echo ok)","Check file permissions and mount health inside the sandbox","If bwrap setup fails, re-provision the workspace"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try:\n    data = await ws.read_file(p)\nexcept RuntimeError as e:\n    log.error('sandbox read failed: %s', e)  # stderr is embedded","preventionTips":["Monitor embedded stderr to distinguish bwrap breakage from app errors","Smoke-test bwrap after environment changes"],"tags":["bubblewrap","runtime","sandbox","io"],"backgroundTag":"sandbox-command-failed","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}