{"record":{"id":"88ffe27e666753d3","repo":"thanos-io/thanos","slug":"no-ignore-chunk-function-specified","errorCode":null,"errorMessage":"no ignore chunk function specified","messagePattern":"no ignore chunk function specified","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/index.go","lineNumber":417,"sourceCode":"\n\tstats.ChunkMaxDuration = time.Duration(chunkDuration.max) * time.Millisecond\n\tstats.ChunkAvgDuration = time.Duration(chunkDuration.Avg()) * time.Millisecond\n\tstats.ChunkMinDuration = time.Duration(chunkDuration.min) * time.Millisecond\n\treturn stats, nil\n}\n\ntype ignoreFnType func(mint, maxt int64, prev *chunks.Meta, curr *chunks.Meta) (bool, error)\n\n// Repair open the block with given id in dir and creates a new one with fixed data.\n// It:\n// - removes out of order duplicates\n// - all \"complete\" outsiders (they will not accessed anyway)\n// - removes all near \"complete\" outside chunks introduced by https://github.com/prometheus/tsdb/issues/347.\n// Fixable inconsistencies are resolved in the new block.\n// TODO(bplotka): https://github.com/thanos-io/thanos/issues/378.\nfunc Repair(ctx context.Context, logger log.Logger, dir string, id ulid.ULID, source metadata.SourceType, ignoreChkFns ...ignoreFnType) (resid ulid.ULID, err error) {\n\tif len(ignoreChkFns) == 0 {\n\t\treturn resid, errors.New(\"no ignore chunk function specified\")\n\t}\n\n\tbdir := filepath.Join(dir, id.String())\n\tentropy := rand.New(rand.NewSource(time.Now().UnixNano()))\n\tresid = ulid.MustNew(ulid.Now(), entropy)\n\n\tmeta, err := metadata.ReadFromDir(bdir)\n\tif err != nil {\n\t\treturn resid, errors.Wrap(err, \"read meta file\")\n\t}\n\tif meta.Thanos.Downsample.Resolution > 0 {\n\t\treturn resid, errors.New(\"cannot repair downsampled block\")\n\t}\n\n\tb, err := tsdb.OpenBlock(logutil.GoKitLogToSlog(logger), bdir, nil, nil)\n\tif err != nil {\n\t\treturn resid, errors.Wrap(err, \"open block\")\n\t}","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/index.go#L399-L435","documentation":"block.Repair requires at least one ignoreChkFn (a predicate deciding which chunks to keep/drop). It rejects the call with \"no ignore chunk function specified\" rather than guessing a repair policy. This is a caller programming error, not a data problem.","triggerScenarios":"Calling Repair(ctx, logger, dir, id, source) with an empty ignoreChkFns variadic list — e.g. passing through user-supplied filters without a default.","commonSituations":"Custom tooling invoking block.Repair directly, wrappers forgetting to append default ignore functions like block.IgnoreIssue347OutsideChunks.","solutions":["Pass at least one ignore function, e.g. block.IgnoreIssue347OutsideChunks when repairing tsdb issue 347 outsiders","Supply caller-appropriate filters explicitly in your repair wrapper","Return a validation error early if no filters are configured"],"exampleFix":"// before\nresid, err := block.Repair(ctx, logger, dir, id, source) // panics with error: no ignore chunk function specified\n// after\nresid, err := block.Repair(ctx, logger, dir, id, source, block.IgnoreIssue347OutsideChunks)","handlingStrategy":"validation","validationCode":"if len(ignoreChkFns) == 0 {\n    ignoreChkFns = []block.IgnoreFn{block.IgnoreIssue347OutsideChunks}\n}","typeGuard":null,"tryCatchPattern":"if len(ignoreChkFns) == 0 {\n    return ulid.ULID{}, errors.New(\"repair requires at least one ignore chunk function\")\n}\nresid, err := block.Repair(ctx, logger, dir, id, source, ignoreChkFns...)","preventionTips":["Always provide explicit repair policies when calling block.Repair","Wrap Repair in a helper that enforces a default ignore function","Review variadic call sites when refactoring repair tooling"],"tags":["api-misuse","repair","arguments"],"backgroundTag":"missing-required-argument","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"}