{"record":{"id":"076e8e116ac2de0a","repo":"thanos-io/thanos","slug":"no-matchers-specified-excluding-selector-labels","errorCode":null,"errorMessage":"no matchers specified (excluding selector labels)","messagePattern":"no matchers specified \\(excluding selector labels\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/proxy.go","lineNumber":300,"sourceCode":"\tsrv := newBatchableServer(seriesSrv, int(originalRequest.ResponseBatchSize))\n\n\t// TODO(bwplotka): This should be part of request logger, otherwise it does not make much sense. Also, could be\n\t// triggered by tracing span to reduce cognitive load.\n\treqLogger := log.With(s.logger, \"component\", \"proxy\")\n\tif s.debugLogging {\n\t\treqLogger = log.With(reqLogger, \"request\", originalRequest.String())\n\t}\n\n\tmatch, matchers, err := matchesExternalLabels(originalRequest.Matchers, s.selectorLabels, s.matcherCache)\n\tif err != nil {\n\t\treturn status.Error(codes.InvalidArgument, err.Error())\n\t}\n\tif !match {\n\t\treturn nil\n\t}\n\n\tif len(matchers) == 0 {\n\t\treturn status.Error(codes.InvalidArgument, errors.New(\"no matchers specified (excluding selector labels)\").Error())\n\t}\n\n\t// We may arrive here either via the promql engine\n\t// or as a result of a grpc call in layered queries\n\tctx := srv.Context()\n\ttenant, foundTenant := tenancy.GetTenantFromGRPCMetadata(ctx)\n\tif !foundTenant {\n\t\tif ctx.Value(tenancy.TenantKey) != nil {\n\t\t\ttenant = ctx.Value(tenancy.TenantKey).(string)\n\t\t}\n\t}\n\n\tctx = metadata.AppendToOutgoingContext(ctx, tenancy.DefaultTenantHeader, tenant)\n\tlevel.Debug(s.logger).Log(\"msg\", \"Tenant info in Series()\", \"tenant\", tenant)\n\n\t// There are no stores registered at all and partial results are disabled, return an error.\n\tstores := s.stores()\n\tif len(stores) == 0 && (originalRequest.PartialResponseDisabled || originalRequest.PartialResponseStrategy == storepb.PartialResponseStrategy_ABORT) {","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/proxy.go#L282-L318","documentation":"The proxy Store's Series gRPC handler requires at least one matcher beyond any automatically added selector (external label) matchers. If len(matchers)==0, it returns an InvalidArgument gRPC status with the message \"no matchers specified (excluding selector labels)\". A query that selects everything (e.g. empty matcher set) is rejected instead of fanning out to all stores.","triggerScenarios":"Calling the storepb Store Series API (or the PromQL engine resolving to it) with an empty matcher list, e.g. promql query `{}` with selectorLabels stripped out, or a client constructing the SeriesRequest without matchers.","commonSituations":"Typo in a PromQL query leaving only the external-label selector (`{cluster=\"x\"}` when cluster is the selector label); programmatic storepb.SeriesRequest built with nil matchers; regression where selector labels were miscounted.","solutions":["Add at least one real label matcher to the query (e.g. {__name__=\"up\"} instead of {})","Review --selector.relabel-config / selector labels to understand which matchers are stripped before this check","If calling the gRPC API programmatically, populate req.Matchers before sending"],"exampleFix":"// before: only selector labels remain, matchers empty\nreq := &storepb.SeriesRequest{MinTime: t0, MaxTime: t1}\n// after: include a concrete matcher\nreq.Matchers = []labels.Matcher{labels.MustNewMatcher(labels.MatchEqual, \"__name__\", \"http_requests_total\")}","handlingStrategy":"validation","validationCode":"if len(req.Matchers) == 0 {\n    return status.Error(codes.InvalidArgument, \"no matchers specified (excluding selector labels)\")\n}","typeGuard":null,"tryCatchPattern":"_, err := storeClient.Series(ctx, req)\nif status.Code(err) == codes.InvalidArgument {\n    // add concrete label matchers (e.g. __name__) before retrying\n}","preventionTips":["Always include at least one non-selector matcher (typically __name__)","Review selector relabel config so it doesn't strip all matchers","Validate PromQL queries client-side for non-empty selectors"],"tags":["thanos","grpc","query","validation"],"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"}