{"record":{"id":"9be062a14afa1aa6","repo":"thanos-io/thanos","slug":"invalid-chunk-type-v","errorCode":null,"errorMessage":"invalid chunk type %v","messagePattern":"invalid chunk type (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/postings_codec.go","lineNumber":353,"sourceCode":"\t\t// and not cause any problems.\n\t\tif len(remainder) > 0 {\n\t\t\tremainderCopy := make([]byte, 0, len(remainder))\n\t\t\tremainderCopy = append(remainderCopy, remainder...)\n\t\t\tremainder = remainderCopy\n\t\t}\n\n\t\tif len(remainder) > 0 {\n\t\t\tit.db.B = append(remainder, uncompressedData...)\n\t\t} else {\n\t\t\tit.db.B = uncompressedData\n\t\t}\n\tdefault:\n\t\tif chunkType <= 0x7f {\n\t\t\tit.err = fmt.Errorf(\"unsupported chunk type %v\", chunkType)\n\t\t\treturn false\n\t\t}\n\t\tif chunkType > 0xfd {\n\t\t\tit.err = fmt.Errorf(\"invalid chunk type %v\", chunkType)\n\t\t\treturn false\n\t\t}\n\t}\n\tit.input = it.input[chunkLen:]\n\n\treturn true\n}\n\nfunc (it *streamedDiffVarintPostings) Next() bool {\n\t// Continue reading next chunks until there is at least binary.MaxVarintLen64.\n\t// If we cannot add any more chunks then return false.\n\tfor {\n\t\tval := it.db.Uvarint64()\n\t\tif it.db.Err() != nil {\n\t\t\tif !it.readNextChunk(it.db.B) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tit.db.E = nil","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/postings_codec.go#L335-L371","documentation":"The chunk header byte was > 0xfd, which is not a valid Snappy-style chunk type (0xfe/0xff are reserved as invalid by the Snappy framing format). This signals the stream is corrupt or not a postings-codec stream, so iteration stops with this error.","triggerScenarios":"Next() reads a chunk type byte > 0xfd, usually because the iterator is consuming garbage bytes after corruption, an incorrect offset, or a truncated/overwritten buffer.","commonSituations":"Reading past the end of valid data (length confusion), corrupted block files, or tools that appended/merged postings blobs incorrectly.","solutions":["Restore the postings data from a healthy source (replica, backup, object storage).","Check the offset/length calculations that produced this buffer; likely reading out of bounds into unrelated bytes.","Re-compact the TSDB block to regenerate valid postings.","Confirm no external tool rewrote the block files."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if len(blob) > 0 && blob[0] > 0xfd {\n    return fmt.Errorf(\"invalid leading chunk type byte: %#x\", blob[0])\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard length/offset calculations to avoid reading past valid data.","Treat any decode error as block corruption; restore from replica.","Do not merge or append postings blobs with ad-hoc tools."],"tags":["go","postings","codec","corruption"],"backgroundTag":"invalid-enum-value","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"}