{"record":{"id":"4533bd994359d297","repo":"thanos-io/thanos","slug":"convert-matchers","errorCode":null,"errorMessage":"convert matchers","messagePattern":"convert matchers","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/query/querier.go","lineNumber":362,"sourceCode":"\treturn &lazySeriesSet{create: func() (storage.SeriesSet, bool) {\n\t\tdefer cancel()\n\t\tdefer span.Finish()\n\n\t\t// Only gets called once, for the first Next() call of the series set.\n\t\tset, ok := <-promise\n\t\tif !ok {\n\t\t\treturn storage.ErrSeriesSet(errors.New(\"channel closed before a value received\")), false\n\t\t}\n\t\treturn set, set.Next()\n\t}}\n}\n\nconst SeriesHashLabelName = \"__cf_series_hash__\"\n\nfunc (q *querier) selectFn(ctx context.Context, hints *storage.SelectHints, ms ...*labels.Matcher) (storage.SeriesSet, storepb.SeriesStatsCounter, error) {\n\tsms, err := storepb.PromMatchersToMatchers(ms...)\n\tif err != nil {\n\t\treturn nil, storepb.SeriesStatsCounter{}, errors.Wrap(err, \"convert matchers\")\n\t}\n\n\taggrs := aggrsFromFunc(hints.Func)\n\tmaxResolutionMillis := maxResolutionFromSelectHints(q.maxResolutionMillis, hints.Range, hints.Func)\n\n\t// TODO(bwplotka): Pass it using the SeriesRequest instead of relying on context.\n\tctx = context.WithValue(ctx, store.StoreMatcherKey, q.storeDebugMatchers)\n\n\t// TODO(bwplotka): Use inprocess gRPC when we want to stream responses.\n\t// Currently streaming won't help due to nature of the both PromQL engine which\n\t// pulls all series before computations anyway.\n\tresp := &seriesServer{ctx: ctx}\n\treq := storepb.SeriesRequest{\n\t\tMinTime:                 hints.Start,\n\t\tMaxTime:                 hints.End,\n\t\tLimit:                   int64(hints.Limit),\n\t\tMatchers:                sms,\n\t\tMaxResolutionWindow:     maxResolutionMillis,","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/query/querier.go#L344-L380","documentation":"selectFn first converts PromQL label matchers to storepb (gRPC store API) matchers via storepb.PromMatchersToMatchers. This fails when a matcher uses a value or regex the storepb format cannot represent, and the error is wrapped as 'convert matchers'.","triggerScenarios":"Passing a *labels.Matcher with an unsupported match type or malformed regex into querier.Select, which reaches selectFn and fails PromMatchersToMatchers.","commonSituations":"Queries with unusual regex constructs not supported by the RE2-based store conversion, or third-party clients sending custom matcher types.","solutions":["Simplify the PromQL matchers in the query (avoid exotic regex)","Validate matchers before querying; ensure standard match types (=, !=, =~, !~)","Check Thanos/Prometheus version compatibility of matcher conversion","Inspect the wrapped cause in the error for the exact failing matcher"],"exampleFix":"// before\n{__name__=~\"foo|bar\",job=~\"(?i)web\"} // unsupported regex flags\n// after\n{__name__=~\"foo|bar\",job=~\"[Ww][Ee][Bb]\"}","handlingStrategy":"validation","validationCode":"for _, m := range ms {\n    switch m.Type {\n    case labels.MatchEqual, labels.MatchNotEqual, labels.MatchRegexp, labels.MatchNotRegexp:\n    default:\n        return fmt.Errorf(\"unsupported matcher type %v for %s\", m.Type, m.Name)\n    }\n    if _, err := regexp.Compile(m.Value); err != nil {\n        return fmt.Errorf(\"invalid regex for %s: %w\", m.Name, err)\n    }\n}","typeGuard":"func isStoreSafeMatcher(m *labels.Matcher) bool {\n    switch m.Type {\n    case labels.MatchEqual, labels.MatchNotEqual, labels.MatchRegexp, labels.MatchNotRegexp:\n        _, err := regexp.Compile(m.Value)\n        return err == nil\n    }\n    return false\n}","tryCatchPattern":"if err := ss.Err(); err != nil {\n    var we error\n    if errors.As(err, &we) && strings.Contains(err.Error(), \"convert matchers\") {\n        return nil, fmt.Errorf(\"bad selector: %w\", we)\n    }\n}","preventionTips":["Only build matchers with the four standard PromQL match types","Pre-compile regexes with RE2 in client code","Validate user-supplied selectors before Select"],"tags":["thanos","query","matchers","conversion"],"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"}