{"record":{"id":"7dc8a278ebedb876","repo":"thanos-io/thanos","slug":"failed-to-convert-matchers","errorCode":null,"errorMessage":"failed to convert matchers","messagePattern":"failed to convert matchers","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/receive.go","lineNumber":421,"sourceCode":"\t\t\t\t\t}, nil\n\t\t\t\t}\n\t\t\t\treturn nil, errors.New(\"Not ready\")\n\t\t\t}),\n\t\t\tinfo.WithExemplarsInfoFunc(),\n\t\t\tinfo.WithStatusInfoFunc(),\n\t\t)\n\n\t\tstatusSrv := status.NewServer(\n\t\t\tcomponent.Receive.String(),\n\t\t\tstatus.WithTSDBStatisticsGetter(\n\t\t\t\tstatus.TSDBStatisticsGetterFunc(func(limit int, matchers []storepb.LabelMatcher) (map[string]tsdb.Stats, error) {\n\t\t\t\t\tif !httpProbe.IsReady() {\n\t\t\t\t\t\treturn nil, errors.New(\"not ready\")\n\t\t\t\t\t}\n\n\t\t\t\t\tpromMatchers, err := storepb.MatchersToPromMatchers(matchers...)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, errors.Wrap(err, \"failed to convert matchers\")\n\t\t\t\t\t}\n\n\t\t\t\t\t// Build the list of tenant IDs if the request matches\n\t\t\t\t\t// against exact tenant values only.\n\t\t\t\t\tvar tenantIDs []string\n\t\t\t\t\tfor _, promMatcher := range promMatchers {\n\t\t\t\t\t\tif promMatcher.Name != conf.tenantLabelName {\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif promMatcher.Type != labels.MatchEqual {\n\t\t\t\t\t\t\ttenantIDs = nil\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttenantIDs = append(tenantIDs, promMatcher.Value)\n\t\t\t\t\t}\n","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/receive.go#L403-L439","documentation":"Inside the Status server's TSDB statistics getter, gRPC label matchers are converted to Prometheus matchers with storepb.MatchersToPromMatchers. If any matcher has an invalid type/value combination, the conversion fails and the error is wrapped with 'failed to convert matchers' and returned to the RPC caller.","triggerScenarios":"Sending a TSDB statistics request whose []storepb.LabelMatcher contains an invalid matcher — e.g. an unknown matcher type or a regex matcher with a pattern that does not compile as a Prometheus regexp.","commonSituations":"Client tooling constructing matchers with a wrong MatchType enum value; regex patterns with syntax Prometheus's regex engine (RE2) rejects; corrupted/manual protobuf requests.","solutions":["Validate the regex patterns in your matchers compile under RE2 (Go regexp) before sending.","Check that each matcher's MatchType is a supported storepb type (EQ, NEQ, RE, NRE).","Fix the client code building the matchers and retry the request.","If using a third-party tool, upgrade it to a version that emits valid matchers."],"exampleFix":"// before\nmatcher := &storepb.LabelMatcher{Type: storepb.LabelMatcher_RE, Name: \"job\", Value: \"(\"} // invalid regex\n// after\nmatcher := &storepb.LabelMatcher{Type: storepb.LabelMatcher_RE, Name: \"job\", Value: \"prometheus.*\"}","handlingStrategy":"validation","validationCode":"for _, m := range matchers {\n  if _, err := regexp.Compile(m.Value); err != nil {\n    return fmt.Errorf(\"invalid matcher regex %q for %q: %w\", m.Value, m.Name, err)\n  }\n}\nif _, err := storepb.MatchersToPromMatchers(matchers...); err != nil { return err }","typeGuard":"func validMatcherType(t storepb.LabelMatcher_Type) bool {\n  switch t {\n  case storepb.LabelMatcher_EQ, storepb.LabelMatcher_NEQ, storepb.LabelMatcher_RE, storepb.LabelMatcher_NRE:\n    return true\n  }\n  return false\n}","tryCatchPattern":"stats, err := statusClient.TSDBStatistics(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"failed to convert matchers\") {\n  return fmt.Errorf(\"fix client-side matchers (type/regex): %w\", err)\n}","preventionTips":["Pre-compile regexes with Go regexp (RE2) before sending","Restrict matcher construction to typed helpers, not raw enums","Fuzz/test client matcher builders","Log the full matcher list when this error occurs"],"tags":["grpc","matchers","regex","validation"],"backgroundTag":"invalid-regex-pattern","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"}