grpc/grpc-go · error
cannot have exclude and a '*' wildcard
Error message
cannot have exclude and a '*' wildcard
What it means
Returned by validateLogEventMethod (gcp/observability/config.go:80) when a methods entry equals exactly "*" AND the exclude flag on that RPC-events block is true. The "*" wildcard selects all methods; using it with exclude:true would mean 'exclude everything' which is nonsensical for logging, so the config rejects it. The check at line 78 short-circuits: a bare "*" is only valid when exclude is false.
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 03255a9237)
Solutions
- Either set exclude:false with "*" (log everything), or keep exclude:true but list specific methods to exclude.
- To express 'log everything except a few', use one inclusive block with "*" (exclude:false) and a separate mechanism, or list the methods you want with exclude semantics.
- Re-read the config docs: '*' is not allowed when exclude is true.
Example fix
// before
{"client_rpc_events":[{"methods":["*"],"exclude":true}]} // err
// after (log everything)
{"client_rpc_events":[{"methods":["*"]}]}
// or exclude specific methods:
{"client_rpc_events":[{"methods":["foo.Bar/Noisy"],"exclude":true}]} Defensive patterns
Strategy: validation
Validate before calling
for _, m := range methods {
if m == "*" && exclude {
return errors.New("'*' wildcard is not allowed when exclude is true")
}
} Try / catch
if _, err := unmarshalAndVerifyConfig(raw); err != nil { log.Fatalf("observability: %v", err) } Prevention
- Document the exclude+wildcard rule next to your config template.
- Prefer explicit method lists over broad wildcards with exclude.
When it happens
Trigger: An observability config block like {"methods":["*"],"exclude":true} in either client_rpc_events or server_rpc_events. Surfaces during unmarshalAndVerifyConfig while parsing GRPC_GCP_OBSERVABILITY_CONFIG(_FILE).
Common situations: Wanting 'log nothing except X' and incorrectly modeling it as exclude:true with a wildcard; copy-pasting an exclude block and adding a wildcard; misunderstanding that exclude works on the listed method set, not as a global toggle.
Related errors
- cannot have a leading slash
- / must come in between service and method, only one /
- method name must be non empty
- empty token_exchange_service_uri in options
- required field SubjectTokenPath is not specified
AI-assisted analysis of grpc/grpc-go@03255a9237 (2026-08-07).
Data as JSON: /api/errors/df91f71472bda573.
Report an issue: GitHub.