grpc/grpc-go · warning
empty string is not a valid method binary logging config
Error message
empty string is not a valid method binary logging config
What it means
Returned by fillMethodLoggerWithConfigString when a single comma-separated segment of the binary-log config string is empty. NewLoggerFromConfigString splits the config by commas and processes each part; an empty part (e.g., from a trailing comma or double comma) is not a valid method pattern. The empty config string itself ("") returns a nil logger and does not reach this function, so this error specifically fires for empty segments within a non-empty config.
Source
Thrown at internal/binarylog/env_config.go:65
return nil
}
l := newEmptyLogger()
methods := strings.Split(s, ",")
for _, method := range methods {
if err := l.fillMethodLoggerWithConfigString(method); err != nil {
grpclogLogger.Warningf("failed to parse binary log config: %v", err)
return nil
}
}
return l
}
// fillMethodLoggerWithConfigString parses config, creates TruncatingMethodLogger and adds
// it to the right map in the logger.
func (l *logger) fillMethodLoggerWithConfigString(config string) error {
// "" is invalid.
if config == "" {
return errors.New("empty string is not a valid method binary logging config")
}
// "-service/method", blacklist, no * or {} allowed.
if config[0] == '-' {
s, m, suffix, err := parseMethodConfigAndSuffix(config[1:])
if err != nil {
return fmt.Errorf("invalid config: %q, %v", config, err)
}
if m == "*" {
return fmt.Errorf("invalid config: %q, %v", config, "* not allowed in blacklist config")
}
if suffix != "" {
return fmt.Errorf("invalid config: %q, %v", config, "header/message limit not allowed in blacklist config")
}
if err := l.setBlacklist(s + "/" + m); err != nil {
return fmt.Errorf("invalid config: %v", err)
}
return nilView on GitHub (pinned to 0c51461d27)
Solutions
- Remove trailing or duplicate commas from the binary log filter string.
- Validate the config string before applying it: split by comma and ensure no empty segments.
- Check gRPC warning logs ('failed to parse binary log config') if binary logging appears inactive.
Example fix
# before GRPC_BINARY_LOG_FILTER="Foo/*," # trailing comma → error, logging disabled # after GRPC_BINARY_LOG_FILTER="Foo/*" # valid
Defensive patterns
Strategy: validation
Validate before calling
// Validate the binary log filter string before applying:
for _, part := range strings.Split(filter, ",") {
if part == "" {
return fmt.Errorf("binary log filter has an empty segment (check trailing/double commas): %q", filter)
}
} Prevention
- Avoid trailing and double commas in GRPC_BINARY_LOG_FILTER.
- Validate filter strings before setting the env var.
- Check gRPC warning logs ('failed to parse binary log config') if logging is unexpectedly disabled.
When it happens
Trigger: Setting GRPC_BINARY_LOG_FILTER to a value with a trailing comma (e.g., Foo/*,) or double comma (e.g., Foo/*,,Foo/Bar), or calling NewLoggerFromConfigString with such a string. Each empty segment triggers the error, which causes the entire logger to be discarded (returns nil).
Common situations: Operators edit the GRPC_BINARY_LOG_FILTER env var and accidentally introduce stray commas. Config-management tooling concatenates filter segments with commas and produces a trailing comma. The resulting nil logger silently disables binary logging, which is hard to notice without checking logs for the warning.
Related errors
- cannot have a leading slash
- / must come in between service and method, only one /
- method name must be non empty
- cannot have exclude and a '*' wildcard
- rls: GrpcKeyBuilder in RouteLookupConfig has required_match
AI-assisted analysis of grpc/grpc-go@0c51461d27 (2026-08-11).
Data as JSON: /api/errors/6af754fb70d50473.
Report an issue: GitHub.