{"record":{"id":"f39fd74eebec00e3","repo":"FoundationAgents/OpenManus","slug":"source-file-is-empty-src-path","errorCode":null,"errorMessage":"Source file is empty: {src_path}","messagePattern":"Source file is empty: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"app/sandbox/core/sandbox.py","lineNumber":290,"sourceCode":"            # Get file stream\n            resolved_src = self._safe_resolve_path(src_path)\n            stream, stat = await asyncio.to_thread(\n                self.container.get_archive, resolved_src\n            )\n\n            # Create temporary directory to extract file\n            with tempfile.TemporaryDirectory() as tmp_dir:\n                # Write stream to temporary file\n                tar_path = os.path.join(tmp_dir, \"temp.tar\")\n                with open(tar_path, \"wb\") as f:\n                    for chunk in stream:\n                        f.write(chunk)\n\n                # Extract file\n                with tarfile.open(tar_path) as tar:\n                    members = tar.getmembers()\n                    if not members:\n                        raise FileNotFoundError(f\"Source file is empty: {src_path}\")\n\n                    # If destination is a directory, we should preserve relative path structure\n                    if os.path.isdir(dst_path):\n                        tar.extractall(dst_path)\n                    else:\n                        # If destination is a file, we only extract the source file's content\n                        if len(members) > 1:\n                            raise RuntimeError(\n                                f\"Source path is a directory but destination is a file: {src_path}\"\n                            )\n\n                        with open(dst_path, \"wb\") as dst:\n                            src_file = tar.extractfile(members[0])\n                            if src_file is None:\n                                raise RuntimeError(\n                                    f\"Failed to extract file: {src_path}\"\n                                )\n                            dst.write(src_file.read())","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/FoundationAgents/OpenManus/blob/52a13f2a57d8c7f6737eefb02ccf569594d44273/app/sandbox/core/sandbox.py#L272-L308","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the source has content first: run_command(f\"ls -la {src_path}\").","If copying a directory is intended, handle empty as a normal case (skip or create the empty dst dir) instead of erroring.","Wait for the producing job to finish before copying its output dir."],"exampleFix":"# before\nawait sandbox.copy_from(\"/workspace/out\", host_dir)\n\n# after\nlisting = await sandbox.run_command(\"find /workspace/out -type f | head -1\")\nif listing.strip():\n    await sandbox.copy_from(\"/workspace/out\", host_dir)\nelse:\n    os.makedirs(host_dir, exist_ok=True)  # nothing to copy yet","handlingStrategy":"validation","validationCode":"nonempty = (await sandbox.run_command(f\"find {shlex.quote(src)} -type f | head -1\")).strip() != \"\"","typeGuard":null,"tryCatchPattern":"try:\n    await sandbox.copy_from(src, dst)\nexcept FileNotFoundError as e:\n    if \"is empty\" in str(e):\n        os.makedirs(dst, exist_ok=True)  # empty source -> empty dest, not an error\n    else:\n        raise","preventionTips":["Check the source dir has files before copying","Treat empty output dirs as a normal outcome of failed/early jobs","Gate artifact copies on producer completion"],"tags":["sandbox","file-io","tar","empty-result","copy"],"backgroundTag":null,"analyzedSha":"52a13f2a57d8c7f6737eefb02ccf569594d44273","analyzedAt":"2026-08-15T02:33:49.993Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}