thanos-io/thanos · error
unrecognized matcher type
Error message
unrecognized matcher type %d
What it means
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.
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.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pkg/store/storepb/custom.go:388 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/92bc571df3f6bde4.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/store/storepb/custom.go:388
// PromMatchersToMatchers returns proto matchers from Prometheus matchers.
// NOTE: It allocates memory.
func PromMatchersToMatchers(ms ...*labels.Matcher) ([]LabelMatcher, error) {
res := make([]LabelMatcher, 0, len(ms))
for _, m := range ms {
var t LabelMatcher_Type
switch m.Type {
case labels.MatchEqual:
t = LabelMatcher_EQ
case labels.MatchNotEqual:
t = LabelMatcher_NEQ
case labels.MatchRegexp:
t = LabelMatcher_RE
case labels.MatchNotRegexp:
t = LabelMatcher_NRE
default:
return nil, errors.Errorf("unrecognized matcher type %d", m.Type)
}
res = append(res, LabelMatcher{Type: t, Name: m.Name, Value: m.Value})
}
return res, nil
}
// MatchersToPromMatchers returns Prometheus matchers from proto matchers.
// NOTE: It allocates memory.
func MatchersToPromMatchers(ms ...LabelMatcher) ([]*labels.Matcher, error) {
res := make([]*labels.Matcher, 0, len(ms))
for i := range ms {
pm, err := MatcherToPromMatcher(ms[i])
if err != nil {
return nil, err
}
res = append(res, pm)
}
return res, nilView on GitHub (pinned to 35b8b99117)