{"record":{"id":"36e0532410810b69","repo":"dotnet/efcore","slug":"unsupported-compression-format-file-extension","errorCode":null,"errorMessage":"Unsupported compression format: {file_extension}","messagePattern":"Unsupported compression format: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"eng/common/cross/install-debs.py","lineNumber":332,"sourceCode":"            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()\n                dctx.copy_stream(zst_file, decompressed_file)\n\n            tar_file_path = decompressed_tar_path\n            mode = \"r\"\n        else:\n            raise ValueError(f\"Unsupported compression format: {file_extension}\")\n\n        with tarfile.open(tar_file_path, mode) as tar:\n            tar.extractall(path=extract_dir, filter=_rootfs_extraction_filter)\n\ndef _rootfs_extraction_filter(member, dest_path):\n    \"\"\"Tarfile extraction filter based on the 'data' filter that additionally\n    rewrites absolute-target symlinks/hardlinks into rootfs-relative paths.\n    \"\"\"\n    if (member.issym() or member.islnk()) and os.path.isabs(member.linkname):\n        link_dir = os.path.dirname(member.name)\n        new_linkname = os.path.relpath(member.linkname.lstrip('/'),\n                                       start=link_dir or '.')\n        member = member.replace(linkname=new_linkname, deep=False)\n    return tarfile.data_filter(member, dest_path)\n\ndef finalize_setup(rootfsdir):\n    lib_dir = os.path.join(rootfsdir, 'lib')\n    usr_lib_dir = os.path.join(rootfsdir, 'usr', 'lib')","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/eng/common/cross/install-debs.py#L314-L350","documentation":"Raised by extract_deb_file (a ValueError) when the data.tar member's file extension, taken via os.path.splitext, is not one of .xz, .gz, or .zst. tarfile.open needs a mode per compression, and the script only knows those three.","triggerScenarios":"The data.tar member inside the .deb has an extension other than .xz/.gz/.zst, e.g. .bz2 (bzip2), .lzma, an uncompressed .tar, or a name whose final extension via splitext is unexpected.","commonSituations":"An older or atypical build using bzip2, a minimal deb with an uncompressed data.tar, or a member name like data.tar.gz.xz where splitext returns .xz (fine) vs data.tar.bz2 where it returns .bz2 (unsupported).","solutions":["Run `ar t <deb_file>` to see the exact data.tar member name and its extension.","If it is .bz2, add an `elif file_extension == '.bz2': mode = 'r:bz2'` branch.","If it is an uncompressed .tar (or empty extension), add `elif file_extension in ('.tar',''): mode = 'r'`.","For an unsupported format like .lzma, pre-decompress it manually (lzma -d) then point tarfile at the result."],"exampleFix":"// before\nif file_extension == \".xz\": mode = \"r:xz\"\nelif file_extension == \".gz\": mode = \"r:gz\"\nelif file_extension == \".zst\": ...\nelse: raise ValueError(f\"Unsupported compression format: {file_extension}\")\n\n// after\nif file_extension == \".xz\": mode = \"r:xz\"\nelif file_extension == \".gz\": mode = \"r:gz\"\nelif file_extension == \".zst\": ...\nelif file_extension == \".bz2\": mode = \"r:bz2\"\nelif file_extension in (\".tar\", \"\"): mode = \"r\"\nelse: raise ValueError(f\"Unsupported compression format: {file_extension}\")","handlingStrategy":"validation","validationCode":"# preflight: enumerate data.tar members across all debs and ensure each extension is supported\nimport subprocess\nsupported = {\".xz\", \".gz\", \".zst\"}\nfor deb in deb_files:\n    members = subprocess.run([ar_tool, \"t\", deb], capture_output=True, text=True).stdout.split()\n    exts = {os.path.splitext(m)[1].lower() for m in members if m.startswith(\"data.tar\")}\n    if not exts <= supported:\n        sys.exit(f\"{deb} uses unsupported data.tar compression {exts - supported}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Handle every compression Debian uses: add .bz2 and plain .tar branches to extract_deb_file.","Inspect ar t output for any deb that fails to learn its real member name.","Pin to mirrors that ship the compression your code path supports (modern debs are .zst or .xz)."],"tags":["deb","extraction","compression","tarfile"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}