{"record":{"id":"a76ed1cda23f7387","repo":"thanos-io/thanos","slug":"unsupported-chunk-encoding-d","errorCode":null,"errorMessage":"unsupported chunk encoding %d","messagePattern":"unsupported chunk encoding (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/bucket.go","lineNumber":1428,"sourceCode":"func populateChunk(out *storepb.AggrChunk, in chunkenc.Chunk, aggrs []storepb.Aggr, save func([]byte) ([]byte, error), calculateChecksum bool) error {\n\thasher := hashPool.Get().(hash.Hash64)\n\tdefer hashPool.Put(hasher)\n\n\tif in.Encoding() == chunkenc.EncXOR || in.Encoding() == chunkenc.EncHistogram || in.Encoding() == chunkenc.EncFloatHistogram {\n\t\tb, err := save(in.Bytes())\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tout.Raw = &storepb.Chunk{\n\t\t\tData: b,\n\t\t\tType: chunkToStoreEncoding(in.Encoding()),\n\t\t\tHash: hashChunk(hasher, b, calculateChecksum),\n\t\t}\n\t\treturn nil\n\t}\n\n\tif in.Encoding() != downsample.ChunkEncAggr {\n\t\treturn errors.Errorf(\"unsupported chunk encoding %d\", in.Encoding())\n\t}\n\n\tac := downsample.AggrChunk(in.Bytes())\n\n\tfor _, at := range aggrs {\n\t\tswitch at {\n\t\tcase storepb.Aggr_COUNT:\n\t\t\tx, err := ac.Get(downsample.AggrCount)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"aggregate %s does not exist\", downsample.AggrCount)\n\t\t\t}\n\t\t\tb, err := save(x.Bytes())\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tout.Count = &storepb.Chunk{Type: chunkToStoreEncoding(x.Encoding()), Data: b, Hash: hashChunk(hasher, b, calculateChecksum)}\n\t\tcase storepb.Aggr_SUM:\n\t\t\tx, err := ac.Get(downsample.AggrSum)","sourceCodeStart":1410,"sourceCodeEnd":1446,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/bucket.go#L1410-L1446","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Run a Thanos bucket verify / inspect on the bucket to find corrupted blocks and repair them via the compactor.","Ensure store gateway and compactor versions match so encodings are interpreted consistently.","If reproducible, open an issue with the block ID — this usually indicates data corruption, not caller error."],"exampleFix":"// verify block consistency before serving\ncor, err := bucket.NewTracingReader(bkt).Read(ctx, \"objects/<blockID>/meta.json\")\nif meta.Resolution > 0 && hasRawXORChunks(cor) {\n    // repair: re-downsample or delete the inconsistent block\n}","handlingStrategy":"validation","validationCode":"if chunk.Encoding() != downsample.ChunkEncAggr {\n    // do not route this chunk to the downsampled/aggregates serving path\n    return fmt.Errorf(\"chunk encoding %d is not aggregate-encoded; cannot serve aggregates\", chunk.Encoding())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify block meta.json resolution matches actual chunk encodings before serving.","Run periodic bucket verify to catch corrupted downsampled blocks.","Keep compactor and store gateway on compatible versions."],"tags":["thanos","storage","downsampling","data-corruption"],"backgroundTag":"unsupported-operation","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}