FoundationAgents/OpenManus · error · RuntimeError
Failed to extract file: {src_path}
Error message
Failed to extract file: {src_path} What it means
Raised as RuntimeError by DockerSandbox.copy_from (app/sandbox/core/sandbox.py:305) when tar.extractfile(members[0]) returns None. extractfile returns None for members that carry no data stream — directories, symlinks, devices, FIFOs. So the archive's first member is not a regular file even though the tar had exactly one member.
Source
Thrown at app/sandbox/core/sandbox.py:305
with tarfile.open(tar_path) as tar:
members = tar.getmembers()
if not members:
raise FileNotFoundError(f"Source file is empty: {src_path}")
# If destination is a directory, we should preserve relative path structure
if os.path.isdir(dst_path):
tar.extractall(dst_path)
else:
# If destination is a file, we only extract the source file's content
if len(members) > 1:
raise RuntimeError(
f"Source path is a directory but destination is a file: {src_path}"
)
with open(dst_path, "wb") as dst:
src_file = tar.extractfile(members[0])
if src_file is None:
raise RuntimeError(
f"Failed to extract file: {src_path}"
)
dst.write(src_file.read())
except docker.errors.NotFound:
raise FileNotFoundError(f"Source file not found: {src_path}")
except Exception as e:
raise RuntimeError(f"Failed to copy file: {e}")
async def copy_to(self, src_path: str, dst_path: str) -> None:
"""Copies a file to the container.
Args:
src_path: Source file path (host).
dst_path: Destination path (container).
Raises:
FileNotFoundError: If source file does not exist.View on GitHub (pinned to 52a13f2a57)
Solutions
- Check what the source is: run_command(f"ls -ld {src_path}") — copy real files with copy_from or the whole tree as a directory dst.
- If src is a symlink, resolve it in the container first (readlink) and copy the target.
- Use a directory destination so tar.extractall handles mixed member types.
Example fix
# before
await sandbox.copy_from("latest", "./latest") # 'latest' is a symlink -> RuntimeError
# after
target = (await sandbox.run_command("readlink -f latest")).strip()
await sandbox.copy_from(target, "./latest") Defensive patterns
Strategy: try-catch
Validate before calling
kind = (await sandbox.run_command(f"ls -ld {shlex.quote(src)}")).split()[0]
regular = kind.startswith("-") Try / catch
try:
await sandbox.copy_from(src, dst)
except RuntimeError as e:
if "Failed to extract" in str(e):
real = (await sandbox.run_command(f"readlink -f {shlex.quote(src)}")).strip()
await sandbox.copy_from(real, dst)
else:
raise Prevention
- Resolve symlinks with readlink -f before copying
- Check ls -ld output: '-' means regular file, safe for single-file copy
- Use directory destinations for anything that may be a tree
When it happens
Trigger: src_path is a directory containing a single subdirectory (one member: the subdir entry); src is a symlink whose link target is the only member; special files (sockets/fifos) in the archive.
Common situations: Copying a path that is actually a symlink created by a build step; copying a directory with one empty subdir; docker get_archive on a path whose parent structure yields a non-regular first entry.
Related errors
- Source file is empty: {src_path}
- Source path is a directory but destination is a file: {src_p
- Failed to copy file: {e}
- Failed to read file: {e}
- Source file not found: {src_path}
AI-assisted analysis of FoundationAgents/OpenManus@52a13f2a57 (2026-08-15).
Data as JSON: /api/errors/731a7df8fda9ed57.
Report an issue: GitHub.