JuliusBrussee/caveman · error
invalid decompression limit %d
Error message
invalid decompression limit %d
What it means
DecompressLimit rejects a maxBytes ceiling that is negative or above the DefaultMaxDecompressedBytes cap (128 MiB). The at-fault input is the caller-supplied limit itself: callers with trusted metadata may lower the bound but may not raise it past the defensive default, preventing a caller from accidentally disabling the decompression-bomb protection.
Source
Thrown at shared/platform/objectstore/compress.go:68
return zstdEnc.EncodeAll(data, nil), nil
default:
return nil, fmt.Errorf("unknown compression codec %q", codec)
}
}
// Decompress reverses Compress with a defensive default expansion ceiling. An
// unknown codec fails closed.
func Decompress(codec string, data []byte) ([]byte, error) {
return DecompressLimit(codec, data, DefaultMaxDecompressedBytes)
}
// DecompressLimit reverses Compress while refusing to produce more than
// maxBytes of plaintext. The limit is applied while decoding gzip and through
// zstd's decoder memory bound, so highly-compressible hostile payloads cannot
// first allocate their full expanded size and only then be rejected.
func DecompressLimit(codec string, data []byte, maxBytes int64) ([]byte, error) {
if maxBytes < 0 || maxBytes > DefaultMaxDecompressedBytes {
return nil, fmt.Errorf("invalid decompression limit %d", maxBytes)
}
switch codec {
case CompressionNone, "":
if int64(len(data)) > maxBytes {
return nil, ErrDecompressedTooLarge
}
return data, nil
case CompressionGzip:
zr, err := gzip.NewReader(bytes.NewReader(data))
if err != nil {
return nil, fmt.Errorf("gzip reader: %w", err)
}
defer zr.Close()
out, err := io.ReadAll(io.LimitReader(zr, maxBytes+1))
if err != nil {
return nil, fmt.Errorf("gzip read: %w", err)
}
if int64(len(out)) > maxBytes {View on GitHub (pinned to 766dce6b13)
Solutions
- Pass a limit between 0 and DefaultMaxDecompressedBytes (128 MiB)
- Use Decompress (no explicit limit) if the default ceiling is what you want
- Fix the size-metadata source that produced a negative or oversized limit value
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at shared/platform/objectstore/compress.go:68 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/dbc2fd7e5aa22f3d.
Report an issue: GitHub.