{"record":{"id":"a30ec818bd7046f3","repo":"thanos-io/thanos","slug":"invalidargument","errorCode":"InvalidArgument","errorMessage":"no matchers specified (excluding external labels)","messagePattern":"no matchers specified \\(excluding external labels\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/exemplars/proxy.go","lineNumber":76,"sourceCode":"\nfunc (s *Proxy) Exemplars(req *exemplarspb.ExemplarsRequest, srv exemplarspb.Exemplars_ExemplarsServer) error {\n\tspan, ctx := tracing.StartSpan(srv.Context(), \"proxy_exemplars\")\n\tdefer span.Finish()\n\n\texpr, err := extpromql.ParseExpr(req.Query)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmatch, selectors := selectorsMatchesExternalLabels(parser.ExtractSelectors(expr), s.selectorLabels)\n\n\t// There is no matched selectors for this thanos query.\n\tif !match {\n\t\treturn nil\n\t}\n\n\tif len(selectors) == 0 {\n\t\treturn status.Error(codes.InvalidArgument, errors.New(\"no matchers specified (excluding external labels)\").Error())\n\t}\n\n\tvar (\n\t\tg, gctx   = errgroup.WithContext(ctx)\n\t\trespChan  = make(chan *exemplarspb.ExemplarData, 10)\n\t\texemplars []*exemplarspb.ExemplarData\n\t)\n\n\tqueryParts := make([]string, 0)\n\tlabelMatchers := make([]string, 0)\n\tfor _, st := range s.exemplars() {\n\t\tqueryParts = queryParts[:0]\n\n\t\tfor _, matcherSet := range selectors {\n\t\t\textLbls := st.LabelSets\n\t\t\tif !store.LabelSetsMatch(matcherSet, extLbls...) {\n\t\t\t\tcontinue\n\t\t\t}","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/exemplars/proxy.go#L58-L94","documentation":"The exemplars proxy rejects requests whose selector list is empty after external labels are stripped, returning codes.InvalidArgument with \"no matchers specified (excluding external labels)\". Exemplar queries require at least one real matcher; labels injected as external labels don't count.","triggerScenarios":"Calling proxy.Exemplars where ExtractSelectors/label matching yields zero selectors — e.g. a query whose only matchers equal the configured external labels, so they are all removed before validation at pkg/exemplars/proxy.go:76.","commonSituations":"Queries like `{__name__=\"up\"}` where the whole selector is stripped as external-label overlap, frontend configs with overly broad external-label replication rules, or clients sending empty matcher lists.","solutions":["Add at least one matcher that is not covered by external labels, e.g. `{job=\"prometheus\"}`.","Review the query-frontend external-label configuration so user matchers are not being stripped.","Validate selectors client-side before calling the Exemplars API.","If the call is intentional fallback behavior, guard the caller (the anonymous wrapper) to skip exemplars queries with no selectors."],"exampleFix":"// before\nqueryExemplars(\"{tenant_id=\\\"x\\\"}\") // fully stripped as external label\n// after\nqueryExemplars(\"{tenant_id=\\\"x\\\", job=\\\"node\\\"}\")","handlingStrategy":"validation","validationCode":"func hasSelectors(query string, externalLabels labels.Labels) error {\n\tsel, err := parser.ParseMetricSelector(query)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, m := range sel {\n\t\tif externalLabels.Get(m.Name) == \"\" || externalLabels.Get(m.Name) != m.Value {\n\t\t\treturn nil // at least one non-external matcher\n\t\t}\n\t}\n\treturn errors.New(\"no matchers specified (excluding external labels)\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Include at least one job/instance-level matcher in exemplars queries.","Keep external-label replication rules narrow so user selectors survive stripping.","Validate selectors in the client before issuing the request."],"tags":["go","grpc","exemplars","selectors","promql"],"backgroundTag":"missing-required-argument","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"}