containerd/containerd · error
unsupported compression format %s
Error message
unsupported compression format %s
What it means
DecompressStream dispatches on the Compression value to create a decompressing io.Reader. The default branch fires when the compression value is not one of the supported algorithms (Uncompressed, Gzip, Bzip2, Xz, Zstd, etc.), producing this error with the compression's Extension() name. It indicates an unknown/invalid Compression constant.
Source
Thrown at pkg/archive/compression/compression.go:240
}, nil
case Zstd:
zstdReader, err := zstd.NewReader(buf,
zstd.WithDecoderLowmem(false),
)
if err != nil {
return nil, err
}
return &readCloserWrapper{
Reader: zstdReader,
compression: compression,
closer: func() error {
zstdReader.Close()
return nil
},
}, nil
default:
return nil, fmt.Errorf("unsupported compression format %s", (&compression).Extension())
}
}
// CompressStream compresses the dest with specified compression algorithm.
func CompressStream(dest io.Writer, compression Compression) (io.WriteCloser, error) {
switch compression {
case Uncompressed:
return &writeCloserWrapper{dest, nil}, nil
case Gzip:
return gzip.NewWriter(dest), nil
case Zstd:
return zstd.NewWriter(dest)
default:
return nil, fmt.Errorf("unsupported compression format %s", (&compression).Extension())
}
}
// Extension returns the extension of a file that uses the specified compression algorithm.View on GitHub (pinned to 4246446a2b)
Solutions
- Use a valid Compression constant from the package (Uncompressed, Gzip, Bzip2, Xz, Zstd) rather than a raw value
- Check the source media type / Content-Type that produced the Compression value and ensure the mapping is correct
- Upgrade the compression package/containerd to a version supporting the format in question
- If decompressing user input, validate the detected compression before calling DecompressStream
Example fix
// before
c := compression.Compression(7)
r, err := compression.DecompressStream(reader) // unsupported
// after
if c != compression.Uncompressed && c != compression.Gzip && c != compression.Zstd { /* handle */ }
r, err := compression.DecompressStream(reader) Defensive patterns
Strategy: validation
Validate before calling
func knownCompression(c compression.Compression) bool {
switch c {
case compression.Uncompressed, compression.Gzip, compression.Bzip2, compression.Xz, compression.Zstd:
return true
}
return false
}
if !knownCompression(c) { return fmt.Errorf("unknown compression %v", c) } Type guard
func isKnown(c compression.Compression) bool {
return c == compression.Uncompressed || c == compression.Gzip || c == compression.Zstd
} Try / catch
r, err := compression.DecompressStream(reader)
if err != nil {
if strings.Contains(err.Error(), "unsupported compression format") {
// fall back to reading raw or upgrade client for newer formats
}
return err
} Prevention
- Derive Compression only from package constants, never int casts
- Validate media types against supported algorithms before mapping
- Keep the compression package updated for newer formats
When it happens
Trigger: Calling DecompressStream(reader) with a Compression value outside the known set — e.g. a zero-value Compression not equal to Uncompressed, a corrupted/discovered media-type mapping yielding an undefined algorithm, or an integer-constructed Compression.
Common situations: Pulling/parsing layer descriptors whose media type maps to an unknown algorithm; hand-constructing Compression from an int; a newer image format compressed with an algorithm this containerd/compression build doesn't know (version mismatch); passing the result of DetectCompression on garbage input.
Related errors
- unrecognized image format
- invalid archive
- short write copying file
- xattrs not supported on Windows
- failed to get stream processor for %s: %w
AI-assisted analysis of containerd/containerd@4246446a2b (2026-09-02).
Data as JSON: /api/errors/65ce3f697d7e38f7.
Report an issue: GitHub.