{"record":{"id":"0da6907646593cf4","repo":"FoundationAgents/OpenManus","slug":"file-not-found-path","errorCode":null,"errorMessage":"File not found: {path}","messagePattern":"File not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"app/sandbox/core/sandbox.py","lineNumber":194,"sourceCode":"            FileNotFoundError: If file does not exist.\n            RuntimeError: If read operation fails.\n        \"\"\"\n        if not self.container:\n            raise RuntimeError(\"Sandbox not initialized\")\n\n        try:\n            # Get file archive\n            resolved_path = self._safe_resolve_path(path)\n            tar_stream, _ = await asyncio.to_thread(\n                self.container.get_archive, resolved_path\n            )\n\n            # Read file content from tar stream\n            content = await self._read_from_tar(tar_stream)\n            return content.decode(\"utf-8\")\n\n        except NotFound:\n            raise FileNotFoundError(f\"File not found: {path}\")\n        except Exception as e:\n            raise RuntimeError(f\"Failed to read file: {e}\")\n\n    async def write_file(self, path: str, content: str) -> None:\n        \"\"\"Writes content to a file in the container.\n\n        Args:\n            path: Target path.\n            content: File content.\n\n        Raises:\n            RuntimeError: If write operation fails.\n        \"\"\"\n        if not self.container:\n            raise RuntimeError(\"Sandbox not initialized\")\n\n        try:\n            resolved_path = self._safe_resolve_path(path)","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/FoundationAgents/OpenManus/blob/52a13f2a57d8c7f6737eefb02ccf569594d44273/app/sandbox/core/sandbox.py#L176-L212","documentation":"Raised as FileNotFoundError by DockerSandbox.read_file (app/sandbox/core/sandbox.py:194) when the Docker get_archive call for the resolved path raises docker.errors.NotFound — the path simply does not exist inside the container (relative paths are resolved under config.work_dir via _safe_resolve_path). It is the container-side equivalent of a missing file, not a host path problem.","triggerScenarios":"Reading an output file before the command that produces it has run; typo in the filename; path resolved against work_dir when the file actually lives elsewhere in the container; the creating process failed silently so the file was never written.","commonSituations":"Agent loop reads `/app/result.json` right after a command that errored before writing it; relative path 'out.txt' expected at CWD but resolved to work_dir; file written by a different user inside the container (rare) or deleted by a cleanup step.","solutions":["Verify existence first: await sandbox.run_command(f\"test -e {path} && echo OK\").","Check the resolved location — relative paths join to config.work_dir; use the absolute container path you wrote to.","Ensure the producing command succeeded (check its exit status/output) before reading its output file.","List the directory (run_command('ls -la <dir>')) to confirm names."],"exampleFix":"# before\ncontent = await sandbox.read_file(\"result.txt\")\n\n# after\nif (await sandbox.run_command(\"test -e result.txt && echo yes\")).strip() == \"yes\":\n    content = await sandbox.read_file(\"result.txt\")\nelse:\n    ...  # producer never wrote the file","handlingStrategy":"try-catch","validationCode":"exists = (await sandbox.run_command(f\"test -e {shlex.quote(path)} && echo 1\")).strip() == \"1\"","typeGuard":null,"tryCatchPattern":"try:\n    content = await sandbox.read_file(path)\nexcept FileNotFoundError:\n    content = None  # producer has not written it yet — schedule retry","preventionTips":["Check producer command exit status before reading outputs","Use the exact absolute path the writer used","Treat FileNotFoundError as an expected branch in agent loops"],"tags":["sandbox","file-io","not-found","docker-api"],"backgroundTag":null,"analyzedSha":"52a13f2a57d8c7f6737eefb02ccf569594d44273","analyzedAt":"2026-08-15T02:33:49.993Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}