thanos-io/thanos · error

unsupported chunk encoding

Error message

unsupported chunk encoding %d

What it means

This error comes from Thanos' store gateway bucket store when it receives a chunkset whose encoding is not downsample.ChunkEncAggr (the aggregate-chunk encoding). The store can only serve downsampled data out of AggrChunk containers that bundle COUNT/SUM/MIN/MAX/COUNTER aggregates; anything else cannot be decomposed into the requested aggregates, so the request is rejected. It is an internal invariant check, not an input the caller normally controls.

Solutions

  1. Inspect the offending block's meta.json (resolution, downsampling) and verify the chunks inside are Aggr-encoded; if the block is inconsistent, delete/re-upload it.
  2. Run a Thanos bucket verify / inspect on the bucket to find corrupted blocks and repair them via the compactor.
  3. Ensure store gateway and compactor versions match so encodings are interpreted consistently.
  4. If reproducible, open an issue with the block ID — this usually indicates data corruption, not caller error.

Example fix

// verify block consistency before serving
cor, err := bucket.NewTracingReader(bkt).Read(ctx, "objects/<blockID>/meta.json")
if meta.Resolution > 0 && hasRawXORChunks(cor) {
    // repair: re-downsample or delete the inconsistent block
}
Defensive patterns

Strategy: validation

Validate before calling

if chunk.Encoding() != downsample.ChunkEncAggr {
    // do not route this chunk to the downsampled/aggregates serving path
    return fmt.Errorf("chunk encoding %d is not aggregate-encoded; cannot serve aggregates", chunk.Encoding())
}

Prevention

When it happens

Trigger: A gRPC Series request against a store view serving downsampled block data resolves a chunk whose Prometheus chunkenc.Encoding is not EncAggr (value 3) — e.g. a plain XOR/Histogram chunk reached the downsample-serving path because block metadata or bucket contents disagree with the block's downsampling resolution.

Common situations: Corrupted or partially-uploaded downsampled blocks in object storage; a block labeled as downsampled (resolution > 0) that actually contains raw XOR chunks; custom code building synthetic AggrChunks with wrong encodings; Thanos version mismatches between compactor-written blocks and store gateway reader.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at pkg/store/bucket.go:1428

func populateChunk(out *storepb.AggrChunk, in chunkenc.Chunk, aggrs []storepb.Aggr, save func([]byte) ([]byte, error), calculateChecksum bool) error {
	hasher := hashPool.Get().(hash.Hash64)
	defer hashPool.Put(hasher)

	if in.Encoding() == chunkenc.EncXOR || in.Encoding() == chunkenc.EncHistogram || in.Encoding() == chunkenc.EncFloatHistogram {
		b, err := save(in.Bytes())
		if err != nil {
			return err
		}
		out.Raw = &storepb.Chunk{
			Data: b,
			Type: chunkToStoreEncoding(in.Encoding()),
			Hash: hashChunk(hasher, b, calculateChecksum),
		}
		return nil
	}

	if in.Encoding() != downsample.ChunkEncAggr {
		return errors.Errorf("unsupported chunk encoding %d", in.Encoding())
	}

	ac := downsample.AggrChunk(in.Bytes())

	for _, at := range aggrs {
		switch at {
		case storepb.Aggr_COUNT:
			x, err := ac.Get(downsample.AggrCount)
			if err != nil {
				return errors.Errorf("aggregate %s does not exist", downsample.AggrCount)
			}
			b, err := save(x.Bytes())
			if err != nil {
				return err
			}
			out.Count = &storepb.Chunk{Type: chunkToStoreEncoding(x.Encoding()), Data: b, Hash: hashChunk(hasher, b, calculateChecksum)}
		case storepb.Aggr_SUM:
			x, err := ac.Get(downsample.AggrSum)

View on GitHub (pinned to 35b8b99117)