{"record":{"id":"731a7df8fda9ed57","repo":"FoundationAgents/OpenManus","slug":"failed-to-extract-file-src-path","errorCode":null,"errorMessage":"Failed to extract file: {src_path}","messagePattern":"Failed to extract file: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"app/sandbox/core/sandbox.py","lineNumber":305,"sourceCode":"                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())\n\n        except docker.errors.NotFound:\n            raise FileNotFoundError(f\"Source file not found: {src_path}\")\n        except Exception as e:\n            raise RuntimeError(f\"Failed to copy file: {e}\")\n\n    async def copy_to(self, src_path: str, dst_path: str) -> None:\n        \"\"\"Copies a file to the container.\n\n        Args:\n            src_path: Source file path (host).\n            dst_path: Destination path (container).\n\n        Raises:\n            FileNotFoundError: If source file does not exist.","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/FoundationAgents/OpenManus/blob/52a13f2a57d8c7f6737eefb02ccf569594d44273/app/sandbox/core/sandbox.py#L287-L323","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nawait sandbox.copy_from(\"latest\", \"./latest\")  # 'latest' is a symlink -> RuntimeError\n\n# after\ntarget = (await sandbox.run_command(\"readlink -f latest\")).strip()\nawait sandbox.copy_from(target, \"./latest\")","handlingStrategy":"try-catch","validationCode":"kind = (await sandbox.run_command(f\"ls -ld {shlex.quote(src)}\")).split()[0]\nregular = kind.startswith(\"-\")","typeGuard":null,"tryCatchPattern":"try:\n    await sandbox.copy_from(src, dst)\nexcept RuntimeError as e:\n    if \"Failed to extract\" in str(e):\n        real = (await sandbox.run_command(f\"readlink -f {shlex.quote(src)}\")).strip()\n        await sandbox.copy_from(real, dst)\n    else:\n        raise","preventionTips":["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"],"tags":["sandbox","copy","tar","symlink","file-type"],"backgroundTag":null,"analyzedSha":"52a13f2a57d8c7f6737eefb02ccf569594d44273","analyzedAt":"2026-08-15T02:33:49.993Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}