{"record":{"id":"8e544e8e632bf4e4","repo":"agentscope-ai/agentscope","slug":"not-found-in-bubblewrap-sandbox-path","errorCode":null,"errorMessage":"not found in Bubblewrap sandbox: {path}","messagePattern":"not found in Bubblewrap sandbox: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/agentscope/workspace/_bubblewrap/_bubblewrap_backend.py","lineNumber":270,"sourceCode":"        sandbox_path = self._sandbox_path_for(path)\n        result = await self.exec_shell(\n            [\n                \"sh\",\n                \"-c\",\n                (\n                    '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,","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/workspace/_bubblewrap/_bubblewrap_backend.py#L252-L288","documentation":"read_file executes a shell cat inside the bwrap sandbox and maps exit code 66 to FileNotFoundError. It means the sandboxed process could not find the requested path: the file does not exist inside the container's mounted view.","triggerScenarios":"Calling read_file on a path that was never written, was deleted inside/outside the sandbox, or lives outside the mounted workdir so it is simply absent in the sandbox.","commonSituations":"Reading a file before the agent created it, referencing a path from the host that was never copied into the workspace, or a race where another process removed the file.","solutions":["Verify the file exists with list_dir/exist checks (or try/except FileNotFoundError) before reading","Write the file into the sandbox workspace first","Check for typos in absolute sandbox paths — only SANDBOX_WORKDIR and SANDBOX_TMPDIR are visible"],"exampleFix":"# before\ndata = await ws.read_file('/workspace/out.txt')\n# after\ntry:\n    data = await ws.read_file('/workspace/out.txt')\nexcept FileNotFoundError:\n    data = ''","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try:\n    data = await ws.read_file(path)\nexcept FileNotFoundError:\n    data = None  # treat as missing","preventionTips":["Check existence via list_dir before reading","Create files before referencing them in orchestration flows"],"tags":["bubblewrap","file-not-found","sandbox"],"backgroundTag":"file-not-found","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}