{"record":{"id":"91cbdd74b1392c1f","repo":"thanos-io/thanos","slug":"new-toc","errorCode":null,"errorMessage":"new TOC","messagePattern":"new TOC","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/indexheader/binary_reader.go","lineNumber":247,"sourceCode":"func (r *chunkedIndexReader) readTOC() (*index.TOC, error) {\n\trc, err := r.bkt.GetRange(r.ctx, r.path, int64(r.size-indexTOCLen-crc32.Size), indexTOCLen+crc32.Size)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"get TOC from object storage of %s\", r.path)\n\t}\n\n\ttocBytes, err := io.ReadAll(rc)\n\tif err != nil {\n\t\trunutil.CloseWithErrCapture(&err, rc, \"close toc reader\")\n\t\treturn nil, errors.Wrapf(err, \"get TOC from object storage of %s\", r.path)\n\t}\n\n\tif err := rc.Close(); err != nil {\n\t\treturn nil, errors.Wrap(err, \"close toc reader\")\n\t}\n\n\ttoc, err := index.NewTOCFromByteSlice(realByteSlice(tocBytes))\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"new TOC\")\n\t}\n\treturn toc, nil\n}\n\nfunc (r *chunkedIndexReader) CopySymbols(w io.Writer, buf []byte) (err error) {\n\trc, err := r.bkt.GetRange(r.ctx, r.path, int64(r.toc.Symbols), int64(r.toc.Series-r.toc.Symbols))\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"get symbols from object storage of %s\", r.path)\n\t}\n\tdefer runutil.CloseWithErrCapture(&err, rc, \"close symbol reader\")\n\n\tif _, err := io.CopyBuffer(w, rc, buf); err != nil {\n\t\treturn errors.Wrap(err, \"copy symbols\")\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/indexheader/binary_reader.go#L229-L265","documentation":"The TOC bytes were fetched and the reader closed, but index.NewTOCFromByteSlice failed while parsing the TOC structure (or validating its CRC32). This means the final bytes of the index file are not a well-formed table of contents, so the index-header cannot be built.","triggerScenarios":"newChunkedIndexReader -> readTOC when NewTOCFromByteSlice rejects the tocBytes: wrong TOC offset (r.size from attrs does not match the actual object), truncated index object, or a structurally invalid TOC written by a broken writer.","commonSituations":"Index object truncated mid-upload so the TOC tail is missing; stale attrs.Size after the object was replaced with a different-sized one; blocks corrupted during copy between buckets; CRC mismatch from bit rot.","solutions":["Verify the index object size matches attrs.Size and re-upload the block if the object is truncated.","Delete the corrupt block (or remove it from the bucket) so store/gateway stops loading it; restore from a replica.","If size mismatch came from cached metadata, invalidate the cached attributes and re-fetch.","Run a block integrity check (e.g. thanos tools bucket verify) to identify and quarantine corrupt blocks."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"attrs, _ := bkt.Attributes(ctx, path)\nif attrs.Size < int64(indexTOCLen+crc32.Size) {\n    return fmt.Errorf(\"index %s truncated: %d bytes\", path, attrs.Size)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run periodic bucket verification (thanos tools bucket verify) and quarantine failing blocks.","Ensure block uploads verify size/CRC after transfer.","Restore blocks from replicas before deleting corrupt originals.","Keep block attrs fresh; avoid building headers against stale metadata."],"tags":["corruption","index-header","thanos","parse-error"],"backgroundTag":"checksum-mismatch","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"}