{"record":{"id":"c1bd751120a71d67","repo":"dotnet/efcore","slug":"could-not-find-data-tar-in-deb-file","errorCode":null,"errorMessage":"Could not find 'data.tar.*' in {deb_file}.","messagePattern":"Could not find 'data\\.tar\\.\\*' in (.+?)\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"eng/common/cross/install-debs.py","lineNumber":308,"sourceCode":"\n    print(\"All done!\")\n\ndef extract_deb_file(deb_file, tmp_dir, extract_dir, ar_tool):\n    \"\"\"Extract .deb file contents\"\"\"\n\n    os.makedirs(extract_dir, exist_ok=True)\n\n    with tempfile.TemporaryDirectory(dir=tmp_dir) as tmp_subdir:\n        result = subprocess.run([ar_tool, \"t\", os.path.abspath(deb_file)], cwd=tmp_subdir, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n        tar_filename = None\n        for line in result.stdout.decode().splitlines():\n            if line.startswith(\"data.tar\"):\n                tar_filename = line.strip()\n                break\n\n        if not tar_filename:\n            raise FileNotFoundError(f\"Could not find 'data.tar.*' in {deb_file}.\")\n\n        tar_file_path = os.path.join(tmp_subdir, tar_filename)\n        print(f\"Extracting {tar_filename} from {deb_file}..\")\n\n        with open(tar_file_path, \"wb\") as outfile:\n            subprocess.run([ar_tool, \"p\", os.path.abspath(deb_file), tar_filename], check=True, stdout=outfile, stderr=subprocess.PIPE)\n\n        file_extension = os.path.splitext(tar_file_path)[1].lower()\n\n        if file_extension == \".xz\":\n            mode = \"r:xz\"\n        elif file_extension == \".gz\":\n            mode = \"r:gz\"\n        elif file_extension == \".zst\":\n            # zstd is not supported by standard library yet\n            decompressed_tar_path = tar_file_path.replace(\".zst\", \"\")\n            with open(tar_file_path, \"rb\") as zst_file, open(decompressed_tar_path, \"wb\") as decompressed_file:\n                dctx = zstandard.ZstdDecompressor()","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/eng/common/cross/install-debs.py#L290-L326","documentation":"Raised by extract_deb_file (a FileNotFoundError) when 'ar t' lists the archive members and none of them starts with 'data.tar'. It means the file on disk is not a valid .deb, or its data payload is absent or named differently.","triggerScenarios":"The file at {tmp_dir}/{basename(filename)} is passed to ar t, and no output line begins with 'data.tar'. Typically because the file is not a .deb at all.","commonSituations":"The mirror served an HTML error page (custom 404 page returned with status 200), a partial/truncated download, a proxy injecting an HTML block page, a wrong suite so a different file was downloaded, or a corrupted deb.","solutions":["Inspect the file: run `file <deb_file>` and `head -c 200 <deb_file>` to see whether it is HTML instead of an ar archive.","Run `ar t <deb_file>` manually to see the actual member list.","Verify --mirror/--suite/--arch produce the right download URLs.","Re-run in case it was a transient mirror/CDN issue serving the wrong body."],"exampleFix":"// before\nresult = subprocess.run([ar_tool, \"t\", os.path.abspath(deb_file)], cwd=tmp_subdir, check=True, ...)\n\n// after\nwith open(deb_file, \"rb\") as fh:\n    if fh.read(8) != b\"!<arch>\\n\":\n        raise FileNotFoundError(f\"{deb_file} is not a valid .deb (bad magic bytes)\")\nresult = subprocess.run([ar_tool, \"t\", os.path.abspath(deb_file)], cwd=tmp_subdir, check=True, ...)","handlingStrategy":"validation","validationCode":"# preflight: verify each downloaded file is a real .deb (ar magic) before extracting\nimport os\ndef is_deb(p):\n    with open(p, \"rb\") as fh:\n        return fh.read(8) == b\"!<arch>\\n\"\nbad = [f for f in os.listdir(tmp_dir) if f.endswith(\".deb\") and not is_deb(os.path.join(tmp_dir, f))]\nif bad:\n    sys.exit(f\"downloaded files are not valid .deb (likely HTML error pages): {bad}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After download, sanity-check each .deb's magic bytes (b\"!<arch>\\n\") and reject HTML bodies.","Verify the mirror/suite/arch produce correct URLs so error pages are not served.","Watch for transparent proxies that inject HTML block pages with status 200."],"tags":["deb","extraction","mirror","ar"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}