grpc/grpc-go · error
cannot have exclude and a '*' wildcard
Error message
cannot have exclude and a '*' wildcard
What it means
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.
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.
Example fix
// before
{"client_rpc_events":[{"methods":["*"],"exclude":true}]} // error
// after
{"client_rpc_events":[
{"methods":["*"]},
{"methods":["foo.Bar/Sensitive"],"exclude":true}
]} Defensive patterns
Strategy: validation
Validate before calling
for _, m := range methods {
if m == "*" && exclude {
return fmt.Errorf("cannot use '*' wildcard with exclude=true; list specific methods to exclude")
}
} Prevention
- 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).
When it happens
Trigger: An observability logging config entry has methods: ["*"] and exclude: true. This combination is detected and rejected during config parsing.
Common situations: 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.
Related errors
- cannot have a leading slash
- method name must be non empty
- / must come in between service and method, only one /
- empty string is not a valid method binary logging config
- grpc: the provided default service config is invalid
AI-assisted analysis of grpc/grpc-go@0c51461d27 (2026-08-11).
Data as JSON: /api/errors/df91f71472bda573.
Report an issue: GitHub.
Appendix: source
Thrown at gcp/observability/config.go:80
}
serviceMethod := strings.Split(method, "/")
if len(serviceMethod) != 2 {
return errors.New("/ must come in between service and method, only one /")
}
if serviceMethod[1] == "" {
return errors.New("method name must be non empty")
}
if serviceMethod[0] == "*" {
return errors.New("cannot have service wildcard * i.e. (*/m)")
}
return nil
}
func validateLogEventMethod(methods []string, exclude bool) error {
for _, method := range methods {
if method == "*" {
if exclude {
return errors.New("cannot have exclude and a '*' wildcard")
}
continue
}
if err := validateMethodString(method); err != nil {
return fmt.Errorf("invalid method string: %v, err: %v", method, err)
}
}
return nil
}
func validateLoggingEvents(config *config) error {
if config.CloudLogging == nil {
return nil
}
for _, clientRPCEvent := range config.CloudLogging.ClientRPCEvents {
if err := validateLogEventMethod(clientRPCEvent.Methods, clientRPCEvent.Exclude); err != nil {
return fmt.Errorf("error in clientRPCEvent method: %v", err)
}View on GitHub (pinned to 0c51461d27)