thanos-io/thanos · error
unrecognized label matcher type
Error message
unrecognized label matcher type %d
What it means
The inverse conversion guard: a Thanos LabelMatcher proto carrying a Type outside EQ/NEQ/RE/NRE cannot be mapped to a Prometheus labels.MatchType. Since the proto enum only defines those four values, this fires on out-of-range enum numbers (corrupted or unknown-version wire data), not on normal query input.
Solutions
- Check for version skew between the components exchanging storepb matchers
- Reject/replace the malformed request data at the boundary
- Upgrade both sides to compatible Thanos versions
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pkg/store/storepb/custom.go:423 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/f7a6d330f25c975d.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/store/storepb/custom.go:423
}
return res, nil
}
// MatcherToPromMatcher converts a Thanos label matcher to Prometheus label matcher.
func MatcherToPromMatcher(m LabelMatcher) (*labels.Matcher, error) {
var t labels.MatchType
switch m.Type {
case LabelMatcher_EQ:
t = labels.MatchEqual
case LabelMatcher_NEQ:
t = labels.MatchNotEqual
case LabelMatcher_RE:
t = labels.MatchRegexp
case LabelMatcher_NRE:
t = labels.MatchNotRegexp
default:
return nil, errors.Errorf("unrecognized label matcher type %d", m.Type)
}
return labels.NewMatcher(t, m.Name, m.Value)
}
// MatchersToString converts label matchers to string format.
// String should be parsable as a valid PromQL query metric selector.
func MatchersToString(ms ...LabelMatcher) string {
var res string
for i, m := range ms {
res += m.PromString()
if i < len(ms)-1 {
res += ", "
}
}
return "{" + res + "}"
}
// PromMatchersToString converts prometheus label matchers to string format.View on GitHub (pinned to 35b8b99117)