grpc/grpc-go · warning

conflicting blacklist rules for method %v found

Error message

conflicting blacklist rules for method %v found

What it means

Returned by logger.setMethodMethodLogger when the method is already in l.config.Blacklist (binarylog.go:139-140). You are attempting to set a method logger for a method that was previously blacklisted. The library enforces mutual exclusivity: a method cannot be both blacklisted ('-service/method') and have a logging rule ('service/method{...}').

Source

Thrown at internal/binarylog/binarylog.go:140

//
// 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)
	}
	if l.config.Methods == nil {
		l.config.Methods = make(map[string]*MethodLoggerConfig)
	}
	l.config.Methods[method] = ml
	return nil
}

// Set blacklist method for "-service/method".
func (l *logger) setBlacklist(method string) 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 either the blacklist entry or the method logger entry for the conflicting method
  2. Decide whether to log or blacklist the method and keep only one rule
  3. Review the config string for methods appearing in both blacklist and method sections

Example fix

# before (contradictory: blacklist then log)
export GRPC_BINARY_LOG_FILTER="Foo/*,-Foo/Bar,Foo/Bar{m:256}"

# after (method is logged, not blacklisted)
export GRPC_BINARY_LOG_FILTER="Foo/*,Foo/Bar{m:256}"
Defensive patterns

Strategy: validation

Validate before calling

// Validate that no method is both blacklisted and has a method logger
func validateBinaryLogConfig(s string) error {
    if s == "" {
        return nil
    }
    blacklist := map[string]bool{}
    methods := map[string]bool{}
    for _, part := range strings.Split(s, ",") {
        part = strings.TrimSpace(part)
        if strings.HasPrefix(part, "-") {
            rest := part[1:]
            if brace := strings.Index(rest, "{"); brace >= 0 {
                rest = rest[:brace]
            }
            blacklist[rest] = true
        } else if !strings.HasPrefix(part, "*") {
            if brace := strings.Index(part, "{"); brace >= 0 {
                part = part[:brace]
            }
            if idx := strings.Index(part, "/"); idx >= 0 {
                method := part[idx+1:]
                if method != "*" {
                    methods[part] = true
                }
            }
        }
    }
    for m := range methods {
        if blacklist[m] {
            return fmt.Errorf("method %q is both blacklisted and has a logging rule", m)
        }
    }
    return nil
}

Prevention

When it happens

Trigger: A config string where a method appears first as a blacklist entry and then as a method logger, e.g., '-Foo/Bar,Foo/Bar{m:256}'. fillMethodLoggerWithConfigString processes '-Foo/Bar' first (calling setBlacklist), then 'Foo/Bar{m:256}' calls setMethodMethodLogger which finds the method in Blacklist.

Common situations: A contradictory config where the same method is both excluded from logging and given a logging rule. Typically a mistake when editing or composing the filter string.

Related errors


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