{"record":{"id":"92bc571df3f6bde4","repo":"thanos-io/thanos","slug":"unrecognized-matcher-type-d","errorCode":null,"errorMessage":"unrecognized matcher type %d","messagePattern":"unrecognized matcher type (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/storepb/custom.go","lineNumber":388,"sourceCode":"\n// PromMatchersToMatchers returns proto matchers from Prometheus matchers.\n// NOTE: It allocates memory.\nfunc PromMatchersToMatchers(ms ...*labels.Matcher) ([]LabelMatcher, error) {\n\tres := make([]LabelMatcher, 0, len(ms))\n\tfor _, m := range ms {\n\t\tvar t LabelMatcher_Type\n\n\t\tswitch m.Type {\n\t\tcase labels.MatchEqual:\n\t\t\tt = LabelMatcher_EQ\n\t\tcase labels.MatchNotEqual:\n\t\t\tt = LabelMatcher_NEQ\n\t\tcase labels.MatchRegexp:\n\t\t\tt = LabelMatcher_RE\n\t\tcase labels.MatchNotRegexp:\n\t\t\tt = LabelMatcher_NRE\n\t\tdefault:\n\t\t\treturn nil, errors.Errorf(\"unrecognized matcher type %d\", m.Type)\n\t\t}\n\t\tres = append(res, LabelMatcher{Type: t, Name: m.Name, Value: m.Value})\n\t}\n\treturn res, nil\n}\n\n// MatchersToPromMatchers returns Prometheus matchers from proto matchers.\n// NOTE: It allocates memory.\nfunc MatchersToPromMatchers(ms ...LabelMatcher) ([]*labels.Matcher, error) {\n\tres := make([]*labels.Matcher, 0, len(ms))\n\tfor i := range ms {\n\t\tpm, err := MatcherToPromMatcher(ms[i])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tres = append(res, pm)\n\t}\n\treturn res, nil","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/storepb/custom.go#L370-L406","documentation":"While converting Prometheus label matchers to Thanos proto matchers, the matcher's MatchType did not match any of the four known types (equal, not-equal, regexp, not-regexp). This indicates a version mismatch with the vendored Prometheus library that introduced a new match type, or memory corruption of the matcher — user queries cannot normally produce it.","triggerScenarios":"Thrown at pkg/store/storepb/custom.go:388 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add an explicit case for the new labels.MatchType in the switch in PromMatchersToMatchers and map it to the corresponding storepb LabelMatcher_Type, then regenerate/check storepb bindings.","If the matcher type should never reach the store API, validate and reject it earlier at the API layer so internal conversion never sees an unknown type.","Write a unit test iterating all labels.MatchType values through PromMatchersToMatchers to catch unmapped enum values at compile/test time instead of at runtime.","If a Prometheus upgrade added the type, pin or upgrade the Prometheus dependency deliberately and port the mapping as part of the upgrade."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}