{"record":{"id":"15a9b2921b03ece2","repo":"grpc/grpc-go","slug":"conflicting-blacklist-rules-for-method-v-found","errorCode":null,"errorMessage":"conflicting blacklist rules for method %v found","messagePattern":"conflicting blacklist rules for method (.+?) found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/binarylog/binarylog.go","lineNumber":140,"sourceCode":"//\n// New MethodLogger with same service overrides the old one.\nfunc (l *logger) setServiceMethodLogger(service string, ml *MethodLoggerConfig) error {\n\tif _, ok := l.config.Services[service]; ok {\n\t\treturn fmt.Errorf(\"conflicting service rules for service %v found\", service)\n\t}\n\tif l.config.Services == nil {\n\t\tl.config.Services = make(map[string]*MethodLoggerConfig)\n\t}\n\tl.config.Services[service] = ml\n\treturn nil\n}\n\n// Set method logger for \"service/method\".\n//\n// New MethodLogger with same method overrides the old one.\nfunc (l *logger) setMethodMethodLogger(method string, ml *MethodLoggerConfig) error {\n\tif _, ok := l.config.Blacklist[method]; ok {\n\t\treturn fmt.Errorf(\"conflicting blacklist rules for method %v found\", method)\n\t}\n\tif _, ok := l.config.Methods[method]; ok {\n\t\treturn fmt.Errorf(\"conflicting method rules for method %v found\", method)\n\t}\n\tif l.config.Methods == nil {\n\t\tl.config.Methods = make(map[string]*MethodLoggerConfig)\n\t}\n\tl.config.Methods[method] = ml\n\treturn nil\n}\n\n// Set blacklist method for \"-service/method\".\nfunc (l *logger) setBlacklist(method string) error {\n\tif _, ok := l.config.Blacklist[method]; ok {\n\t\treturn fmt.Errorf(\"conflicting blacklist rules for method %v found\", method)\n\t}\n\tif _, ok := l.config.Methods[method]; ok {\n\t\treturn fmt.Errorf(\"conflicting method rules for method %v found\", method)","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/internal/binarylog/binarylog.go#L122-L158","documentation":"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{...}').","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove either the blacklist entry or the method logger entry for the conflicting method","Decide whether to log or blacklist the method and keep only one rule","Review the config string for methods appearing in both blacklist and method sections"],"exampleFix":"# before (contradictory: blacklist then log)\nexport GRPC_BINARY_LOG_FILTER=\"Foo/*,-Foo/Bar,Foo/Bar{m:256}\"\n\n# after (method is logged, not blacklisted)\nexport GRPC_BINARY_LOG_FILTER=\"Foo/*,Foo/Bar{m:256}\"","handlingStrategy":"validation","validationCode":"// Validate that no method is both blacklisted and has a method logger\nfunc validateBinaryLogConfig(s string) error {\n    if s == \"\" {\n        return nil\n    }\n    blacklist := map[string]bool{}\n    methods := map[string]bool{}\n    for _, part := range strings.Split(s, \",\") {\n        part = strings.TrimSpace(part)\n        if strings.HasPrefix(part, \"-\") {\n            rest := part[1:]\n            if brace := strings.Index(rest, \"{\"); brace >= 0 {\n                rest = rest[:brace]\n            }\n            blacklist[rest] = true\n        } else if !strings.HasPrefix(part, \"*\") {\n            if brace := strings.Index(part, \"{\"); brace >= 0 {\n                part = part[:brace]\n            }\n            if idx := strings.Index(part, \"/\"); idx >= 0 {\n                method := part[idx+1:]\n                if method != \"*\" {\n                    methods[part] = true\n                }\n            }\n        }\n    }\n    for m := range methods {\n        if blacklist[m] {\n            return fmt.Errorf(\"method %q is both blacklisted and has a logging rule\", m)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure no method appears in both the blacklist ('-service/method') and method logger ('service/method{...}') sections","Document the mutual exclusivity of blacklist and method logger rules for your team"],"tags":["grpc","binarylog","config","environment-variables","logging"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}