{"record":{"id":"df91f71472bda573","repo":"grpc/grpc-go","slug":"cannot-have-exclude-and-a-wildcard","errorCode":null,"errorMessage":"cannot have exclude and a '*' wildcard","messagePattern":"cannot have exclude and a '\\*' wildcard","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gcp/observability/config.go","lineNumber":80,"sourceCode":"\t}\n\tserviceMethod := strings.Split(method, \"/\")\n\tif len(serviceMethod) != 2 {\n\t\treturn errors.New(\"/ must come in between service and method, only one /\")\n\t}\n\tif serviceMethod[1] == \"\" {\n\t\treturn errors.New(\"method name must be non empty\")\n\t}\n\tif serviceMethod[0] == \"*\" {\n\t\treturn errors.New(\"cannot have service wildcard * i.e. (*/m)\")\n\t}\n\treturn nil\n}\n\nfunc validateLogEventMethod(methods []string, exclude bool) error {\n\tfor _, method := range methods {\n\t\tif method == \"*\" {\n\t\t\tif exclude {\n\t\t\t\treturn errors.New(\"cannot have exclude and a '*' wildcard\")\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif err := validateMethodString(method); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid method string: %v, err: %v\", method, err)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc validateLoggingEvents(config *config) error {\n\tif config.CloudLogging == nil {\n\t\treturn nil\n\t}\n\tfor _, clientRPCEvent := range config.CloudLogging.ClientRPCEvents {\n\t\tif err := validateLogEventMethod(clientRPCEvent.Methods, clientRPCEvent.Exclude); err != nil {\n\t\t\treturn fmt.Errorf(\"error in clientRPCEvent method: %v\", err)\n\t\t}","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/gcp/observability/config.go#L62-L98","documentation":"Returned by validateLogEventMethod when an entry in the methods list is the bare wildcard '*' and the Exclude flag is true. The '*' wildcard matches all methods; combining it with exclude would mean 'exclude everything', which is nonsensical for a logging config and is therefore rejected. Inclusion with '*' is valid; exclusion with '*' is not.","triggerScenarios":"An observability logging config entry has methods: [\"*\"] and exclude: true. This combination is detected and rejected during config parsing.","commonSituations":"Developers try to express 'log everything except certain methods' by inverting the logic (exclude all, then include specific ones), not realizing the config model uses include-lists with specific excludes, not a global exclude-all.","solutions":["Remove the '*' entry from the methods list when exclude is true; instead list the specific methods you want to exclude.","Restructure the config: use an include entry with methods: [\"*\"] and a separate exclude entry listing the methods to skip."],"exampleFix":"// before\n{\"client_rpc_events\":[{\"methods\":[\"*\"],\"exclude\":true}]} // error\n// after\n{\"client_rpc_events\":[\n  {\"methods\":[\"*\"]},\n  {\"methods\":[\"foo.Bar/Sensitive\"],\"exclude\":true}\n]}","handlingStrategy":"validation","validationCode":"for _, m := range methods {\n    if m == \"*\" && exclude {\n        return fmt.Errorf(\"cannot use '*' wildcard with exclude=true; list specific methods to exclude\")\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never combine '*' with exclude=true.","To exclude specific methods, list them explicitly with exclude=true.","To log all methods, use '*' with exclude=false (the default)."],"tags":["go","grpc","observability","config","validation"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}