{"record":{"id":"478ed542a69b6697","repo":"grpc-ecosystem/grpc-gateway","slug":"selector-q-in-v-must-specify-a-single-service-me","errorCode":null,"errorMessage":"selector %q in %v must specify a single service method without wildcards","messagePattern":"selector %q in (.+?) must specify a single service method without wildcards","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/descriptor/grpc_api_configuration.go","lineNumber":47,"sourceCode":"\n\tserviceConfiguration := apiconfig.GrpcAPIService{}\n\tif err := unmarshaler.Unmarshal(jsonContents, &serviceConfiguration); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse gRPC API Configuration from YAML in %q: %w\", yamlSourceLogName, err)\n\t}\n\n\treturn &serviceConfiguration, nil\n}\n\nfunc registerHTTPRulesFromGrpcAPIService(registry *Registry, service *apiconfig.GrpcAPIService, sourceLogName string) error {\n\tif service.Http == nil {\n\t\t// Nothing to do\n\t\treturn nil\n\t}\n\n\tfor _, rule := range service.Http.GetRules() {\n\t\tselector := \".\" + strings.Trim(rule.GetSelector(), \" \")\n\t\tif strings.ContainsAny(selector, \"*, \") {\n\t\t\treturn fmt.Errorf(\"selector %q in %v must specify a single service method without wildcards\", rule.GetSelector(), sourceLogName)\n\t\t}\n\n\t\tregistry.AddExternalHTTPRule(selector, rule)\n\t}\n\n\treturn nil\n}\n\n// LoadGrpcAPIServiceFromYAML loads a gRPC API Configuration from the given YAML file\n// and registers the HttpRule descriptions contained in it as externalHTTPRules in\n// the given registry. This must be done before loading the proto file.\n//\n// You can learn more about gRPC API Service descriptions from Google's documentation\n// at https://cloud.google.com/endpoints/docs/grpc/grpc-service-config\n//\n// Note that for the purposes of the gateway generator we only consider a subset of all\n// available features google supports in their service descriptions.\nfunc (r *Registry) LoadGrpcAPIServiceFromYAML(yamlFile string) error {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/grpc-ecosystem/grpc-gateway/blob/a58a4436a376a4bcc7d8f10c4d4f919a8438bba9/internal/descriptor/grpc_api_configuration.go#L29-L65","documentation":"registerHTTPRulesFromGrpcAPIService rejects any HttpRule selector containing '*' or spaces (and thus empty selectors), because selectors in gRPC API Configuration must name exactly one fully-qualified service method. Wildcard or multi-method selectors cannot be resolved to a single registration target.","triggerScenarios":"A YAML config http.rules entry with selector like \"pkg.Service*\", \"pkg.*\", a selector containing spaces, or an empty selector, processed via LoadGrpcAPIServiceFromYAML.","commonSituations":"Users expecting wildcard selector support (as in some other gRPC tooling) and writing \"myapp.*\" in gateway YAML; copy-paste leaving trailing spaces or an incomplete method name; template-generated configs where the method name failed to substitute.","solutions":["Replace the wildcard with explicit selectors — one rule per fully-qualified method, e.g. selector: mypkg.MyService.MethodA (one entry per method)","Trim whitespace from selectors in generated configs; remove any spaces inside the selector string","If you need rules for many methods, script the config generation to enumerate methods instead of using wildcards"],"exampleFix":"// before\nhttp:\n  rules:\n    - selector: mypkg.MyService.*\n      get: /v1/items\n// after\nhttp:\n  rules:\n    - selector: mypkg.MyService.GetItem\n      get: /v1/items/{id}\n    - selector: mypkg.MyService.ListItems\n      get: /v1/items","handlingStrategy":"validation","validationCode":"for _, rule := range cfg.Http.Rules {\n    sel := rule.GetSelector()\n    if sel == \"\" || strings.ContainsAny(sel, \"*, \") {\n        return fmt.Errorf(\"selector %q must be a single fully-qualified method\", sel)\n    }\n}","typeGuard":"func isPlainMethodSelector(sel string) bool {\n    return sel != \"\" && !strings.ContainsAny(sel, \"*, \")\n}","tryCatchPattern":"if err := descriptor.LoadGrpcAPIServiceFromYAML(data, name); err != nil {\n    if strings.Contains(err.Error(), \"must specify a single service method\") {\n        grpclog.Fatalf(\"expand wildcard selectors in %s\", name)\n    }\n    return err\n}","preventionTips":["Write one explicit rule per method; grpc-gateway has no wildcard selector support","Strip whitespace from selectors in generated configs","Enumerate methods from your proto descriptor when generating configs instead of hand-writing wildcards"],"tags":["go","grpc-gateway","config","selector","validation"],"backgroundTag":"invalid-grpc-api-selector","analyzedSha":"a58a4436a376a4bcc7d8f10c4d4f919a8438bba9","analyzedAt":"2026-09-02T10:28:31.537Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}