{"record":{"id":"48adda2e2b2fed69","repo":"agentscope-ai/agentscope","slug":"not-found-in-pod-path","errorCode":null,"errorMessage":"not found in Pod: {path}","messagePattern":"not found in Pod: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/agentscope/workspace/_k8s/_k8s_backend.py","lineNumber":235,"sourceCode":"        Returns:\n            `bytes`:\n                The raw file contents.\n\n        Raises:\n            `FileNotFoundError`:\n                If the path does not exist inside the Pod.\n        \"\"\"\n        dirname = posixpath.dirname(path) or \"/\"\n        basename = posixpath.basename(path)\n\n        result = await self.exec_shell(\n            [\"tar\", \"cf\", \"-\", \"-C\", dirname, basename],\n            cwd=\"/\",\n        )\n        if not result.ok():\n            stderr_text = result.stderr.decode(errors=\"replace\")\n            if \"No such file\" in stderr_text or \"not found\" in stderr_text:\n                raise FileNotFoundError(\n                    f\"not found in Pod: {path}\",\n                )\n            raise FileNotFoundError(\n                f\"not found in Pod: {path} (tar stderr: {stderr_text})\",\n            )\n\n        try:\n            tar = tarfile.open(fileobj=io.BytesIO(result.stdout), mode=\"r\")\n        except tarfile.ReadError as exc:\n            raise FileNotFoundError(\n                f\"not found in Pod: {path}\",\n            ) from exc\n\n        try:\n            for member in tar.getmembers():\n                if member.isfile():\n                    f = tar.extractfile(member)\n                    if f:","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/workspace/_k8s/_k8s_backend.py#L217-L253","documentation":"Raised by K8sBackend.read_file() when `tar cf - -C <dir> <basename>` inside the Pod fails and its stderr contains 'No such file' or 'not found'. This is the explicit missing-file branch: the requested path does not exist inside the Kubernetes Pod. Note this backend reads files by tar-streaming them out of the container, so tar's error text is the signal.","triggerScenarios":"`await backend.read_file(path)` where path doesn't exist in the Pod — e.g. a tempfile already cleaned up, a gateway body_file spilled and deleted, or a wrong absolute path.","commonSituations":"Reading a gateway spill file (body_file) that another request already deleted; racing cleanup code; paths built for a different container or the host rather than the Pod; file removed between existence check and read.","solutions":["Verify the path exists first: `await backend.exec_shell([\"test\", \"-f\", path])` and check exit code","Fix path construction to use the in-Pod absolute path","Catch FileNotFoundError and regenerate/recreate the file if it's a transient spill artifact","Serialize read+delete around shared tempfiles to avoid races"],"exampleFix":"// before\ndata = await backend.read_file(spill_path)  # FileNotFoundError\n// after\nif (await backend.exec_shell([\"test\", \"-f\", spill_path])).ok():\n    data = await backend.read_file(spill_path)\nelse:\n    data = b\"\"","handlingStrategy":"validation","validationCode":"if (await backend.exec_shell([\"test\", \"-f\", path])).ok():\n    data = await backend.read_file(path)\nelse:\n    data = None","typeGuard":null,"tryCatchPattern":"try:\n    data = await backend.read_file(path)\nexcept FileNotFoundError:\n    data = None  # treat missing as empty","preventionTips":["Pre-check with `test -f` inside the Pod for optional files","Use absolute in-Pod paths","Avoid racing a concurrent delete_path on the same tempfile"],"tags":["kubernetes","pod","file-not-found","tar"],"backgroundTag":"file-not-found-in-container","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}