kopia/kopia · error
decompression error
Error message
decompression error
What it means
deflateCompressor.Decompress wraps a failure from iocopy.JustCopy while copying decompressed bytes from the flate.Reader to the output. The deflate stream was invalid (corrupt data, bad checksum/trailer) or the output write failed. Corrupt input is the most common cause: flate reports unexpected EOF or corrupt data before flagging it as io errors.
Solutions
- Verify the blob's stored checksum; re-upload/re-fetch if it does not match — corrupt source is the usual cause.
- Run an independent flate/gzip integrity test (gzip -t / python zlib) on the raw bytes to confirm corruption.
- Confirm you use the matching wrapper: library's flate reader expects plain deflate stream, not gzip-wrapped data.
- Check the output writer (disk space, connection) if the unwrapped error is a write error rather than a decode error.
Example fix
// before
err := comp.Decompress(out, bytes.NewReader(blob))
// after
if err := verifyChecksum(blob, expected); err != nil {
return refetchBlob(ctx, id) // corrupt source
}
err := comp.Decompress(out, bytes.NewReader(blob)) Defensive patterns
Strategy: validation
Validate before calling
if len(blob) < 4 { return errors.New("blob too short") }
if sum := sha256.Sum256(blob); !bytes.Equal(sum[:], storedChecksum) {
return errors.New("blob corrupt: checksum mismatch")
}
err := comp.Decompress(out, bytes.NewReader(blob), true) Try / catch
if err := comp.Decompress(out, r, true); err != nil {
if strings.Contains(err.Error(), "decompression error") {
return fmt.Errorf("deflate stream corrupt or output failed: %w", err)
}
return err
} Prevention
- Checksum every compressed blob at write time and verify before reading.
- Ensure readers use the matching compressor (flate vs gzip wrap).
- Keep output sinks healthy (disk space) for large decompressions.
When it happens
Trigger: Calling Decompress on bytes that are not valid deflate: truncated stream, bit-rotted blob, data compressed with raw deflate vs zlib confusion, or output writer errors mid-copy.
Common situations: Partial uploads stored as complete objects; files edited/truncated after compression; reading with the wrong wrap (raw flate vs gzip) so the decoder chokes on header bytes; full disk while writing large output.
Understand the failure class
Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.
Related errors
- decompression error
- decompression error
- error decompressing
- compression close error
- compression close error
AI-assisted analysis of kopia/kopia@82495e54b5 (2026-09-07).
Data as JSON: /api/errors/bdd172691c107969.
Report an issue: GitHub.
Appendix: source
Thrown at repo/compression/compressor_deflate.go:74
if err := w.Close(); err != nil {
return errors.Wrap(err, "compression close error")
}
return nil
}
func (c *deflateCompressor) Decompress(output io.Writer, input io.Reader, withHeader bool) error {
if withHeader {
if err := verifyCompressionHeader(input, c.header); err != nil {
return err
}
}
r := flate.NewReader(input)
if err := iocopy.JustCopy(output, r); err != nil {
return errors.Wrap(err, "decompression error")
}
return nil
}
View on GitHub (pinned to 82495e54b5)