FoundationAgents/OpenManus · error · FileNotFoundError

Source file is empty: {src_path}

Error message

Source file is empty: {src_path}

What it means

Raised as FileNotFoundError by DockerSandbox.copy_from (app/sandbox/core/sandbox.py:290) when the fetched tar archive contains zero members — the source path resolved to an empty archive. Typically this means the path exists but is an empty directory, or the archive produced for it has no entries; distinct from docker NotFound (error 36) which means the path does not exist at all.

Source

Thrown at app/sandbox/core/sandbox.py:290

            # Get file stream
            resolved_src = self._safe_resolve_path(src_path)
            stream, stat = await asyncio.to_thread(
                self.container.get_archive, resolved_src
            )

            # Create temporary directory to extract file
            with tempfile.TemporaryDirectory() as tmp_dir:
                # Write stream to temporary file
                tar_path = os.path.join(tmp_dir, "temp.tar")
                with open(tar_path, "wb") as f:
                    for chunk in stream:
                        f.write(chunk)

                # Extract file
                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())

View on GitHub (pinned to 52a13f2a57)

Solutions

  1. Confirm the source has content first: run_command(f"ls -la {src_path}").
  2. If copying a directory is intended, handle empty as a normal case (skip or create the empty dst dir) instead of erroring.
  3. Wait for the producing job to finish before copying its output dir.

Example fix

# before
await sandbox.copy_from("/workspace/out", host_dir)

# after
listing = await sandbox.run_command("find /workspace/out -type f | head -1")
if listing.strip():
    await sandbox.copy_from("/workspace/out", host_dir)
else:
    os.makedirs(host_dir, exist_ok=True)  # nothing to copy yet
Defensive patterns

Strategy: validation

Validate before calling

nonempty = (await sandbox.run_command(f"find {shlex.quote(src)} -type f | head -1")).strip() != ""

Try / catch

try:
    await sandbox.copy_from(src, dst)
except FileNotFoundError as e:
    if "is empty" in str(e):
        os.makedirs(dst, exist_ok=True)  # empty source -> empty dest, not an error
    else:
        raise

Prevention

When it happens

Trigger: copy_from on an empty directory (tar of an empty dir can have no extractable members); copying a file that was truncated to zero and archived oddly; race where the file is deleted between listing and archiving.

Common situations: Copying an output directory before any outputs were written (job still running or failed early); copying '/tmp' style scratch dirs that happen to be empty.

Related errors


AI-assisted analysis of FoundationAgents/OpenManus@52a13f2a57 (2026-08-15). Data as JSON: /api/errors/f39fd74eebec00e3. Report an issue: GitHub.