agentscope-ai/agentscope · error · FileNotFoundError
not found in Pod: {path} (tar stderr: {stderr_text})
Error message
not found in Pod: {path} (tar stderr: {stderr_text}) What it means
Raised by K8sBackend.read_file() when the in-Pod `tar cf -` fails with an error that does NOT match the known 'No such file'/'not found' patterns. The raw tar stderr is appended. The library still maps it to FileNotFoundError, but the real cause is visible only in the parenthesized stderr — e.g. permission denied, tar not installed, or path syntax errors.
Source
Thrown at src/agentscope/workspace/_k8s/_k8s_backend.py:239
Raises:
`FileNotFoundError`:
If the path does not exist inside the Pod.
"""
dirname = posixpath.dirname(path) or "/"
basename = posixpath.basename(path)
result = await self.exec_shell(
["tar", "cf", "-", "-C", dirname, basename],
cwd="/",
)
if not result.ok():
stderr_text = result.stderr.decode(errors="replace")
if "No such file" in stderr_text or "not found" in stderr_text:
raise FileNotFoundError(
f"not found in Pod: {path}",
)
raise FileNotFoundError(
f"not found in Pod: {path} (tar stderr: {stderr_text})",
)
try:
tar = tarfile.open(fileobj=io.BytesIO(result.stdout), mode="r")
except tarfile.ReadError as exc:
raise FileNotFoundError(
f"not found in Pod: {path}",
) from exc
try:
for member in tar.getmembers():
if member.isfile():
f = tar.extractfile(member)
if f:
return f.read()
finally:
tar.close()
View on GitHub (pinned to e90f1c7592)
Solutions
- Read the tar stderr in the message — it carries the true failure reason
- If tar is missing, use an image that includes tar (or add it) since this backend depends on tar streaming
- For permission errors, adjust the exec user or the file's permissions in the Pod
- Check the path is an absolute in-Pod path, not a host or container-escape path
Defensive patterns
Strategy: try-catch
Validate before calling
res = await backend.exec_shell(["tar", "--version"])
if not res.ok():
raise RuntimeError("tar missing in Pod image; read_file requires tar") Try / catch
try:
data = await backend.read_file(path)
except FileNotFoundError as e:
if "tar stderr" in str(e):
# real cause is in stderr (permissions / missing tar), not a plain miss
logger.error("read_file underlying failure: %s", e)
raise Prevention
- Ensure the Pod image ships tar
- Check directory permissions for the exec user
- Read the parenthesized stderr before assuming the file is missing
When it happens
Trigger: `await backend.read_file(path)` where tar fails for a non-existence reason: 'Permission denied' on the directory, 'tar: command not found' in a minimal image, 'Cannot open: No such file or directory' variants worded differently by the tar implementation (e.g. BusyBox vs GNU tar).
Common situations: Minimal/distroless Pod images without tar; reading files under directories with restrictive permissions (different UID); BusyBox tar wording that doesn't match the pattern; reading a path that is a broken symlink.
Related errors
- not found in Pod: {path}
- write to {path!r} failed: {command[0]} exited {exit_code}: {
- Invalid permission decision behavior: {decision.behavior}
- {kind.value.replace('_', ' ').title()} '{resource_id}' is re
- {entry.path!r} is larger than its declared {entry.size} byte
AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28).
Data as JSON: /api/errors/489c9ba564eb9d19.
Report an issue: GitHub.