{"record":{"id":"dff343ab192578e3","repo":"thanos-io/thanos","slug":"input-block-index-not-valid","errorCode":null,"errorMessage":"input block index not valid","messagePattern":"input block index not valid","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/downsample.go","lineNumber":367,"sourceCode":"\tm *metadata.Meta,\n\tdir string,\n\tresolution int64,\n\thashFunc metadata.HashFunc,\n\tmetrics *DownsampleMetrics,\n\tacceptMalformedIndex bool,\n\tblockFilesConcurrency int,\n) error {\n\tbegin := time.Now()\n\tbdir := filepath.Join(dir, m.ULID.String())\n\n\terr := block.Download(ctx, logger, bkt, m.ULID, bdir, objstore.WithFetchConcurrency(blockFilesConcurrency))\n\tif err != nil {\n\t\treturn compact.NewRetryError(errors.Wrapf(err, \"download block %s\", m.ULID))\n\t}\n\tlevel.Info(logger).Log(\"msg\", \"downloaded block\", \"id\", m.ULID, \"duration\", time.Since(begin), \"duration_ms\", time.Since(begin).Milliseconds())\n\n\tif err := block.VerifyIndex(ctx, logger, filepath.Join(bdir, block.IndexFilename), m.MinTime, m.MaxTime); err != nil && !acceptMalformedIndex {\n\t\treturn errors.Wrap(err, \"input block index not valid\")\n\t}\n\n\tbegin = time.Now()\n\n\tvar pool chunkenc.Pool\n\tif m.Thanos.Downsample.Resolution == 0 {\n\t\tpool = chunkenc.NewPool()\n\t} else {\n\t\tpool = downsample.NewPool()\n\t}\n\n\tb, err := tsdb.OpenBlock(logutil.GoKitLogToSlog(logger), bdir, pool, nil)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"open block %s\", m.ULID)\n\t}\n\tdefer runutil.CloseWithLogOnErr(log.With(logger, \"outcome\", \"potential left mmap file handlers left\"), b, \"tsdb reader\")\n\n\tid, err := downsample.Downsample(ctx, logger, m, b, dir, resolution)","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/downsample.go#L349-L385","documentation":"After downloading, processDownsampling calls block.VerifyIndex and, unless acceptMalformedIndex is set, wraps failures as \"input block index not valid\". The downloaded block's index file fails Thanos's health/consistency verification (index-header mismatches, out-of-range postings, corrupted file).","triggerScenarios":"block.VerifyIndex(ctx, logger, bdir/index, m.MinTime, m.MaxTime) returns error and the --accept-malformed-index flag is false: corrupted or truncated index in the object store, index-header labels/resolution mismatch, malformed index produced by an old buggy Prometheus/Thanos.","commonSituations":"Blocks uploaded before a failed/interrupted upload (missing parts); known historic TSDB index bugs; blocks whose meta minTime/maxTime disagree with the index contents; restoring from a broken backup.","solutions":["Re-upload or regenerate the corrupt block from a healthy source (delete the bad block so it can be re-created from raw data).","Run with --accept-malformed-index if you have assessed the index issue and accept the risk (downsampling may produce partial results).","Verify minTime/maxTime in meta.json match the index; check for known Prometheus index-corruption issues for the version that wrote the block."],"exampleFix":"// before\nthanos downsample --data-dir=/data ...\n// after (after confirming corruption is tolerated)\nthanos downsample --data-dir=/data --accept-malformed-index ...","handlingStrategy":"validation","validationCode":"stats, err := block.GatherIndexHealthStats(ctx, logger, filepath.Join(bdir, block.IndexFilename), meta.MinTime, meta.MaxTime)\nif err != nil || stats.AnyErr() != nil {\n    return fmt.Errorf(\"source block %s index unhealthy, skipping\", meta.ULID)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable --accept-malformed-index only consciously and document the accepted risk.","Keep Prometheus/Thanos versions current to avoid known index-writing bugs.","Verify block completeness (upload markers, checksums) before treating blocks as healthy sources."],"tags":["index","corruption","validation"],"backgroundTag":"schema-validation-failed","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"}