juicedata/juicefs · error

decompress an empty input

Error message

decompress an empty input

What it means

Returned by LZ4.Decompress when the input buffer is empty. LZ4 has no representation for zero-length compressed data, so decompressing nothing is treated as invalid input rather than returning zero bytes.

Source

Thrown at pkg/compress/compress.go:122

// LZ4 implements Compressor using LZ4 library
type LZ4 struct{}

// Name returns name of the algorithm LZ4
func (l LZ4) Name() string { return "LZ4" }

// CompressBound max size of compressed data
func (l LZ4) CompressBound(size int) int { return lz4.CompressBound(size) }

// Compress using LZ4 algorithm
func (l LZ4) Compress(dst, src []byte) (int, error) {
	return lz4.CompressDefault(src, dst)
}

// Decompress using LZ4 algorithm
func (l LZ4) Decompress(dst, src []byte) (int, error) {
	if len(src) == 0 {
		return 0, fmt.Errorf("decompress an empty input")
	}
	return lz4.DecompressSafe(src, dst)
}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Check for empty input before decompressing and handle it as a valid empty payload (or skip).
  2. Investigate why a 0-byte compressed block exists: verify the object in object storage, re-upload or repair the block.
  3. Use `juicefs gc`/fsck-style tooling to find and clean corrupt or empty blocks.

Example fix

// before
n, err := comp.Decompress(dst, src) // panics/errors when src empty

// after
if len(src) == 0 {
    return 0, nil // empty payload is valid
}
n, err := comp.Decompress(dst, src)
Defensive patterns

Strategy: validation

Validate before calling

if len(src) == 0 { /* treat as empty payload; skip decompress */ }

Try / catch

n, err := comp.Decompress(dst, src)
if err != nil && strings.Contains(err.Error(), "empty input") {
    return handleEmptyBlock() // or flag corrupt block for repair
}

Prevention

When it happens

Trigger: Calling LZ4.Decompress(dst, src) with len(src) == 0 — e.g. a zero-length compressed block read from object storage or cache, or passing an empty/nil slice directly.

Common situations: Corrupt or truncated uploads producing 0-byte blocks; volume formatted with lz4 compression but a block was stored empty; bugs in callers that skip empty-data checks before decompressing.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/1aaa138ada84fcbe. Report an issue: GitHub.