{"record":{"id":"0c57c9028b1922f0","repo":"thanos-io/thanos","slug":"missing-magic-snappy-marker","errorCode":null,"errorMessage":"missing magic snappy marker","messagePattern":"missing magic snappy marker","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/postings_codec.go","lineNumber":265,"sourceCode":"\tit.input = it.input[3:]\n\n\tswitch chunkType {\n\tcase chunkTypeStreamIdentifier:\n\t\tconst magicBody = \"sNaPpY\"\n\t\tif chunkLen != len(magicBody) {\n\t\t\tit.err = fmt.Errorf(\"corrupted identifier\")\n\t\t\treturn false\n\t\t}\n\t\tif string(it.input[:len(magicBody)]) != magicBody {\n\t\t\tit.err = fmt.Errorf(\"got bad identifier %s\", string(it.input[:6]))\n\t\t\treturn false\n\t\t}\n\t\tit.input = it.input[6:]\n\t\tit.readSnappyIdentifier = true\n\t\treturn it.readNextChunk(nil)\n\tcase chunkTypeCompressedData:\n\t\tif !it.readSnappyIdentifier {\n\t\t\tit.err = fmt.Errorf(\"missing magic snappy marker\")\n\t\t\treturn false\n\t\t}\n\t\tif len(it.input) < 4 {\n\t\t\tit.err = io.ErrUnexpectedEOF\n\t\t\treturn false\n\t\t}\n\t\tchecksum := uint32(it.input[0]) | uint32(it.input[1])<<8 | uint32(it.input[2])<<16 | uint32(it.input[3])<<24\n\t\tif len(it.input) < chunkLen {\n\t\t\tit.err = io.ErrUnexpectedEOF\n\t\t\treturn false\n\t\t}\n\n\t\tif it.buf == nil {\n\t\t\tif it.disablePooling {\n\t\t\t\tit.buf = make([]byte, it.maximumDecodedLen)\n\t\t\t} else {\n\t\t\t\tb, err := decodedBufPool.Get(it.maximumDecodedLen)\n\t\t\t\tif err != nil {","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/postings_codec.go#L247-L283","documentation":"A chunk of type chunkTypeCompressedData (Snappy-compressed postings) was encountered before the stream's Snappy identifier chunk was read. The format requires the \"sNaPpY\" magic identifier chunk to appear first so the decoder initializes its Snappy state; without it the compressed chunk cannot be trusted, so the iterator fails with this error.","triggerScenarios":"Iterating a postings stream that starts directly with a compressed-data chunk because the leading identifier/magic chunk is missing, was skipped, or the buffer was sliced past it.","commonSituations":"Hand-built or truncated postings buffers, tools that strip the header before re-serving data, or resuming iteration mid-stream after a previous error left readSnappyIdentifier unset.","solutions":["Ensure the full postings blob including the leading Snappy identifier chunk is passed to the decoder; do not slice off the first bytes.","Re-fetch/rebuild the postings data if the header was lost (re-compact the TSDB block).","Restart iteration from the beginning of the blob rather than from an offset after an earlier error.","Check the writing side (postings codec version) matches the reading side."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if !isDiffVarintSnappyEncodedPostings(blob) {\n    return fmt.Errorf(\"stream must start with snappy identifier chunk\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass the entire postings blob from its first byte.","Do not resume iteration mid-stream after errors; restart from the start.","Keep writer and reader codec versions aligned."],"tags":["go","snappy","postings","codec","framing"],"backgroundTag":"invalid-argument-format","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"}