grpc/grpc-go · warning

conflicting service rules for service %v found

Error message

conflicting service rules for service %v found

What it means

Returned by logger.setServiceMethodLogger when the service is already present in l.config.Services (binarylog.go:125-126). Two 'service/*' rules for the same service name exist in the config string. The first creates the entry; the second detects the duplicate and rejects it. This propagates through NewLoggerFromConfigString as a warning with nil logger returned.

Source

Thrown at internal/binarylog/binarylog.go:126

func newEmptyLogger() *logger {
	return &logger{}
}

// Set method logger for "*".
func (l *logger) setDefaultMethodLogger(ml *MethodLoggerConfig) error {
	if l.config.All != nil {
		return fmt.Errorf("conflicting global rules found")
	}
	l.config.All = ml
	return nil
}

// Set method logger for "service/*".
//
// New MethodLogger with same service overrides the old one.
func (l *logger) setServiceMethodLogger(service string, ml *MethodLoggerConfig) error {
	if _, ok := l.config.Services[service]; ok {
		return fmt.Errorf("conflicting service rules for service %v found", service)
	}
	if l.config.Services == nil {
		l.config.Services = make(map[string]*MethodLoggerConfig)
	}
	l.config.Services[service] = ml
	return nil
}

// Set method logger for "service/method".
//
// New MethodLogger with same method overrides the old one.
func (l *logger) setMethodMethodLogger(method string, ml *MethodLoggerConfig) error {
	if _, ok := l.config.Blacklist[method]; ok {
		return fmt.Errorf("conflicting blacklist rules for method %v found", method)
	}
	if _, ok := l.config.Methods[method]; ok {
		return fmt.Errorf("conflicting method rules for method %v found", method)
	}

View on GitHub (pinned to 0c51461d27)

Solutions

  1. Remove the duplicate service rule from the config string
  2. Merge the header/message settings into a single entry for that service
  3. Deduplicate service entries programmatically before setting the env var

Example fix

# before (duplicate service rule)
export GRPC_BINARY_LOG_FILTER="Foo/*{h:256},Foo/*{m:512}"

# after (single merged rule)
export GRPC_BINARY_LOG_FILTER="Foo/*{h:256;m:512}"
Defensive patterns

Strategy: validation

Validate before calling

// Validate for duplicate service rules
func validateBinaryLogConfig(s string) error {
    if s == "" {
        return nil
    }
    services := map[string]bool{}
    for _, part := range strings.Split(s, ",") {
        part = strings.TrimSpace(part)
        if strings.HasPrefix(part, "-") || strings.HasPrefix(part, "*") {
            continue
        }
        // Check if it's a service rule (ends with /*)
        if idx := strings.Index(part, "/"); idx >= 0 {
            svc := part[:idx]
            method := part[idx+1:]
            // Strip suffix braces from method for comparison
            if braceIdx := strings.Index(method, "{"); braceIdx >= 0 {
                method = method[:braceIdx]
            }
            if method == "*" {
                if services[svc] {
                    return fmt.Errorf("duplicate service rule for %q", svc)
                }
                services[svc] = true
            }
        }
    }
    return nil
}

Prevention

When it happens

Trigger: Setting GRPC_BINARY_LOG_FILTER to include two entries for the same service, e.g., 'Foo/*,Foo/*' or 'Foo/*{h:256},Foo/*{m:512}'. The comma-separated parser processes each independently.

Common situations: Duplicate service entries when composing a filter string from multiple sources. Intending to override a service rule but the library does not support overrides for duplicate entries (it treats them as conflicts).

Related errors


AI-assisted analysis of grpc/grpc-go@0c51461d27 (2026-08-11). Data as JSON: /api/errors/3816b08b96147859. Report an issue: GitHub.