{"record":{"id":"2c90531b91d14739","repo":"thanos-io/thanos","slug":"filter-metas","errorCode":null,"errorMessage":"filter metas","messagePattern":"filter metas","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/fetcher.go","lineNumber":687,"sourceCode":"\t\treturn f.fetchMetadata(ctx)\n\t})\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tresp := v.(response)\n\n\t// Copy as same response might be reused by different goroutines.\n\tmetas := make(map[ulid.ULID]*metadata.Meta, len(resp.metas))\n\tmaps.Copy(metas, resp.metas)\n\n\tmetrics.Synced.WithLabelValues(FailedMeta).Set(float64(len(resp.metaErrs)))\n\tmetrics.Synced.WithLabelValues(NoMeta).Set(resp.noMetas)\n\tmetrics.Synced.WithLabelValues(CorruptedMeta).Set(resp.corruptedMetas)\n\n\tfor _, filter := range filters {\n\t\t// NOTE: filter can update synced metric accordingly to the reason of the exclude.\n\t\tif err := filter.Filter(ctx, metas, metrics.Synced, metrics.Modified); err != nil {\n\t\t\treturn nil, nil, errors.Wrap(err, \"filter metas\")\n\t\t}\n\t}\n\n\tmetrics.Synced.WithLabelValues(LoadedMeta).Set(float64(len(metas)))\n\n\tif len(resp.metaErrs) > 0 {\n\t\treturn metas, resp.partial, errors.Wrap(resp.metaErrs.Err(), \"incomplete view\")\n\t}\n\n\tlevel.Info(f.logger).Log(\"msg\", \"successfully synchronized block metadata\", \"duration\", time.Since(start).String(), \"duration_ms\", time.Since(start).Milliseconds(), \"cached\", f.countCached(), \"returned\", len(metas), \"partial\", len(resp.partial))\n\treturn metas, resp.partial, nil\n}\n\nfunc (f *BaseFetcher) countCached() int {\n\tf.mtx.Lock()\n\tdefer f.mtx.Unlock()\n\tvar i int\n\tf.cached.Range(func(_, _ any) bool {","sourceCodeStart":669,"sourceCodeEnd":705,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/fetcher.go#L669-L705","documentation":"In fetchMetadata, after loading metadata the supplied MetadataFilters are applied via filter.Filter(ctx, metas, ...). If any filter returns an error, the whole metadata fetch aborts and the error is wrapped with \"filter metas\". It signals a user-supplied filter (e.g. consistency delay, time-partition, or custom label filters) failed, not the object store itself.","triggerScenarios":"Calling fetchMetadata with filters configured (e.g. ConsistencyDelayMetaFilter, TimePartitionMetaFilter, LabelSelectorMetaFilter, SidecarMetaFilter) where the filter's Filter method returns an error — typically a wrapped underlying failure inside the filter.","commonSituations":"Custom MetadataFilter implementations returning errors on unexpected metadata; consistency-delay filter clock/time parsing issues; sidecar filter failing a store-API call while filtering; misconfigured label selectors in custom filters.","solutions":["Inspect the wrapped error to identify which filter failed and why.","Fix the misconfiguration of that filter (labels, time partitions, consistency delay settings).","If a custom MetadataFilter is at fault, make it tolerant: log-and-skip blocks instead of returning an error.","Temporarily remove the failing filter from the sync options to confirm it is the cause, then correct it."],"exampleFix":"// before: custom filter that aborts sync on any block\nfunc (f *MyFilter) Filter(ctx context.Context, m map[ulid.ULID]*metadata.Meta, ...) error {\n    return fmt.Errorf(\"bad block %s\", ulid)\n}\n// after: log and skip offending blocks instead\nfor id := range bad { delete(m, id); level.Warn(logger).Log(\"msg\", \"filter dropped block\", \"block\", id) }\nreturn nil","handlingStrategy":"try-catch","validationCode":"// Unit-test custom filters with representative metadata before deploying\nif err := myFilter.Filter(ctx, testMetas, metrics.NewBlocksSynced(metrics, nil, []string{}), nil); err != nil {\n    // filter is not tolerant; fix before enabling in sync\n}","typeGuard":null,"tryCatchPattern":"metas, err := fetcher.FetchMetadata(ctx, filtered)\nif err != nil && strings.Contains(err.Error(), \"filter metas\") {\n    // identify the failing filter from the wrapped error; disable/correct it, then retry\n}","preventionTips":["Make custom MetadataFilter implementations log-and-skip instead of returning errors.","Keep consistency delay and label-selectors filter configuration valid for the blocks present.","Test new filters in staging buckets before production sync.","Keep wrapped-error context in filters so the culprit is identifiable from logs."],"tags":["sync","filters","metadata","configuration"],"backgroundTag":"invalid-argument-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"}