dotnet/aspnetcore · error · ValueError
Unsupported compression format: {file_extension}
Error message
Unsupported compression format: {file_extension} What it means
extract_deb_file chooses a tarfile open mode based on the data.tar extension: .xz -> r:xz, .gz -> r:gz, .zst -> decompress via zstandard then r. Any other extension raises ValueError. This guards against a .deb using a compression the rootfs builder cannot decompress. Modern Debian is moving to .zst (zstd), which IS handled via the zstandard library, but more exotic formats (bz2, lz, lzma, or a future format) are not.
Source
Thrown at eng/common/cross/install-debs.py:332
subprocess.run([ar_tool, "p", os.path.abspath(deb_file), tar_filename], check=True, stdout=outfile, stderr=subprocess.PIPE)
file_extension = os.path.splitext(tar_file_path)[1].lower()
if file_extension == ".xz":
mode = "r:xz"
elif file_extension == ".gz":
mode = "r:gz"
elif file_extension == ".zst":
# zstd is not supported by standard library yet
decompressed_tar_path = tar_file_path.replace(".zst", "")
with open(tar_file_path, "rb") as zst_file, open(decompressed_tar_path, "wb") as decompressed_file:
dctx = zstandard.ZstdDecompressor()
dctx.copy_stream(zst_file, decompressed_file)
tar_file_path = decompressed_tar_path
mode = "r"
else:
raise ValueError(f"Unsupported compression format: {file_extension}")
with tarfile.open(tar_file_path, mode) as tar:
tar.extractall(path=extract_dir, filter=_rootfs_extraction_filter)
def _rootfs_extraction_filter(member, dest_path):
"""Tarfile extraction filter based on the 'data' filter that additionally
rewrites absolute-target symlinks/hardlinks into rootfs-relative paths.
"""
if (member.issym() or member.islnk()) and os.path.isabs(member.linkname):
link_dir = os.path.dirname(member.name)
new_linkname = os.path.relpath(member.linkname.lstrip('/'),
start=link_dir or '.')
member = member.replace(linkname=new_linkname, deep=False)
return tarfile.data_filter(member, dest_path)
def finalize_setup(rootfsdir):
lib_dir = os.path.join(rootfsdir, 'lib')
usr_lib_dir = os.path.join(rootfsdir, 'usr', 'lib')View on GitHub (pinned to 294cab2f9b)
Solutions
- Identify the actual extension: 'ar t <deb>' shows the data.tar member name; check its suffix.
- Switch to a suite/mirror whose .debs use .xz or .zst (the supported set).
- If you genuinely need .bz2/.lzma support, extend the switch to add 'r:bz2'/'r:lzma' modes — but prefer using a mainstream mirror.
- Verify the .deb is from an official Debian/Ubuntu repository and not a hand-built package with a non-standard data.tar compression.
Example fix
# before — suite ships .lzma data.tar python3 install-debs.py --suite old-distro ... # ValueError: Unsupported compression format: .lzma # after — use a suite with .xz/.zst debs python3 install-debs.py --suite bookworm ... # or extend support (if you must) # in extract_deb_file: # elif file_extension == '.bz2': # mode = 'r:bz2' # elif file_extension == '.lzma': # mode = 'r:xz'
Defensive patterns
Strategy: validation
Validate before calling
# Pre-check the data.tar compression before extraction
import os
SUPPORTED = {'.xz', '.gz', '.zst'}
def supported_data_tar_compression(deb_file: str, ar: str = 'ar') -> bool:
r = subprocess.run([ar, 't', os.path.abspath(deb_file)], capture_output=True)
for line in r.stdout.decode().splitlines():
if line.startswith('data.tar'):
return os.path.splitext(line.lower())[1] in SUPPORTED
return False Type guard
SUPPORTED = {'.xz', '.gz', '.zst'}
def is_supported_compression(ext: str) -> bool:
return ext.lower() in SUPPORTED Try / catch
try:
extract_deb_file(deb_file, tmp_dir, extract_dir, ar_tool)
except ValueError as e:
if 'Unsupported compression format' in str(e):
ext = str(e).split(':')[-1].strip()
print(f'.deb uses {ext}; extend extract_deb_file or switch to a .xz/.zst suite')
raise
raise Prevention
- Prefer mainstream Debian/Ubuntu suites that use .xz or .zst for data.tar.
- Extend the compression switch (r:bz2, r:lzma) only if a legacy suite is unavoidable.
- Run 'ar t <deb>' in CI to detect unsupported data.tar formats early.
- Document the supported compression set for anyone maintaining install-debs.py.
When it happens
Trigger: The data.tar member inside the .deb has an extension other than .xz/.gz/.zst (e.g., .bz2, .lzma, .tar with no compression, or a doubly-suffixed name the os.path.splitext does not reduce correctly). The switch at install-debs.py:316-332 falls through to the else branch and raises.
Common situations: Older Ubuntu .debs that used .lzma; a custom/patched .deb with bz2 data.tar; a filename like 'data.tar.foo' from a non-standard archive tool; a misconfigured os.path.splitext on a double extension producing an unexpected suffix.
Related errors
- Could not find 'data.tar.*' in {deb_file}.
- SHA256 mismatch for {url}: expected {checksum}, got {sha256}
- Failed to download {url}, Status Code: {response.status}
- Failed to download {url} after {max_retries} attempts.
- SHA256 mismatch for {path}: expected {packages_sha}, got {sh
AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06).
Data as JSON: /api/errors/07c6e7e1c089d508.
Report an issue: GitHub.