{"record":{"id":"4665b7ded217ac2d","repo":"thanos-io/thanos","slug":"populate-chunk","errorCode":null,"errorMessage":"populate chunk","messagePattern":"populate chunk","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/bucket.go","lineNumber":3800,"sourceCode":"\t\treadOffset += n\n\t\t// Unexpected EOF for last chunk could be a valid case. Any other errors are definitely real.\n\t\tif err != nil && !errors.Is(err, io.ErrUnexpectedEOF) && i != len(pIdxs)-1 {\n\t\t\treturn errors.Wrapf(err, \"read range for seq %d offset %x\", seq, pIdx.offset)\n\t\t}\n\n\t\tchunkDataLen, n := binary.Uvarint(cb)\n\t\tif n < 1 {\n\t\t\treturn errors.New(\"reading chunk length failed\")\n\t\t}\n\n\t\t// Chunk length is n (number of bytes used to encode chunk data), 1 for chunk encoding and chunkDataLen for actual chunk data.\n\t\t// There is also crc32 after the chunk, but we ignore that.\n\t\tchunkLen = n + 1 + int(chunkDataLen)\n\t\tif chunkLen <= len(cb) {\n\t\t\tc := rawChunk(cb[n:chunkLen])\n\t\t\terr = populateChunk(&(res[pIdx.seriesEntry].chks[pIdx.chunk]), &c, aggrs, r.save, calculateChunkChecksum)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrap(err, \"populate chunk\")\n\t\t\t}\n\t\t\tstats.add(ChunksTouched, 1, int(chunkDataLen))\n\t\t\tcontinue\n\t\t}\n\n\t\tr.block.metrics.chunkRefetches.WithLabelValues(tenant).Inc()\n\t\t// If we didn't fetch enough data for the chunk, fetch more.\n\t\tfetchBegin = time.Now()\n\t\t// Read entire chunk into new buffer.\n\t\t// TODO: readChunkRange call could be avoided for any chunk but last in this particular part.\n\t\tif err := bytesLimiter.ReserveWithType(uint64(chunkLen), ChunksTouched); err != nil {\n\t\t\treturn httpgrpc.Errorf(int(codes.ResourceExhausted), \"exceeded bytes limit while fetching chunks: %s\", err)\n\t\t}\n\n\t\tnb, err := r.block.readChunkRange(ctx, seq, int64(pIdx.offset), int64(chunkLen), []byteRange{{offset: 0, length: chunkLen}}, r.logger)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"preloaded chunk too small, expecting %d, and failed to fetch full chunk\", chunkLen)\n\t\t}","sourceCodeStart":3782,"sourceCodeEnd":3818,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/bucket.go#L3782-L3818","documentation":"Raised in bucketChunkReader.load when decoding the chunk header yields chunkDataLen but converting/decoding the chunk (b.Toolbox decode of chunk bytes via chunkenc) fails — the chunk bytes fetched are corrupt or the encoding byte is invalid, so the chunk cannot be materialized.","triggerScenarios":"Thrown at pkg/store/bucket.go:3800 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the block's chunks files for corruption (verify checksums)","Re-upload or restore the affected block from a backup","Identify the series/chunk via the wrapped error and query a different replica if available"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}