thanos-io/thanos · error

unsupported chunk type

Error message

unsupported chunk type %v

What it means

The chunk header byte (chunkType) had a value <= 0x7f, which is outside the reserved set of defined chunk types (compressed data, uncompressed data, identifier). The format deliberately leaves values 0x80-0xfd for future Snappy-chunk compatibility; anything <= 0x7f means the framing is not a valid Snappy-style postings stream, so the iterator reports this error.

Solutions

  1. Verify the byte slice passed to the decoder is a complete postings blob with the correct codec header; check upstream offset arithmetic.
  2. Restore or re-generate the postings data — the stream is malformed.
  3. Check that the writer version and reader version use the same postings codec.
  4. Inspect the first bytes of the buffer (hexdump) to confirm it starts with the expected snappy identifier framing.
Defensive patterns

Strategy: validation

Validate before calling

if len(blob) > 0 && blob[0] <= 0x7f && !bytes.HasPrefix(blob, []byte("sNaPpY")) {
    return fmt.Errorf("buffer is not a snappy-framed postings stream")
}

Type guard

func looksLikePostingsBlob(b []byte) bool {
    return len(b) > 6 && bytes.HasPrefix(b, []byte("sNaPpY"))
}

Prevention

When it happens

Trigger: Next() reads a chunk whose first byte is <= 0x7f — the buffer is not postings-codec data at all, the offset is wrong, or the data was written by an incompatible encoder.

Common situations: Pointing a decoder at non-postings binary data (e.g. an index-section offset error), truncated files where a length byte is misread as a chunk type, or custom block tooling that writes invalid chunk types.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/2a4fc5ddc6a2bc4a. Report an issue: GitHub.

Appendix: source

Thrown at pkg/store/postings_codec.go:349

			return false
		}

		// NOTE(GiedriusS): we can probably optimize this better but this should be rare enough
		// and not cause any problems.
		if len(remainder) > 0 {
			remainderCopy := make([]byte, 0, len(remainder))
			remainderCopy = append(remainderCopy, remainder...)
			remainder = remainderCopy
		}

		if len(remainder) > 0 {
			it.db.B = append(remainder, uncompressedData...)
		} else {
			it.db.B = uncompressedData
		}
	default:
		if chunkType <= 0x7f {
			it.err = fmt.Errorf("unsupported chunk type %v", chunkType)
			return false
		}
		if chunkType > 0xfd {
			it.err = fmt.Errorf("invalid chunk type %v", chunkType)
			return false
		}
	}
	it.input = it.input[chunkLen:]

	return true
}

func (it *streamedDiffVarintPostings) Next() bool {
	// Continue reading next chunks until there is at least binary.MaxVarintLen64.
	// If we cannot add any more chunks then return false.
	for {
		val := it.db.Uvarint64()
		if it.db.Err() != nil {

View on GitHub (pinned to 35b8b99117)