{"record":{"id":"38ecb62ac5d3fb9e","repo":"grpc/grpc-go","slug":"conflicting-method-rules-for-method-v-found","errorCode":null,"errorMessage":"conflicting method rules for method %v found","messagePattern":"conflicting method rules for method (.+?) found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/binarylog/binarylog.go","lineNumber":143,"sourceCode":"\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)\n\t}\n\tif l.config.Blacklist == nil {\n\t\tl.config.Blacklist = make(map[string]struct{})","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/internal/binarylog/binarylog.go#L125-L161","documentation":"Returned by logger.setMethodMethodLogger when the method is already in l.config.Methods (binarylog.go:142-143). Two method-level logging rules exist for the same 'service/method' in the config string. The library does not support overriding; it treats duplicate method entries as conflicts.","triggerScenarios":"A config string with two entries for the same method, e.g., 'Foo/Bar{m:256},Foo/Bar{m:512}'. The first sets l.config.Methods[\"Foo/Bar\"], the second finds it already present and errors.","commonSituations":"Duplicate method entries when manually composing the filter string. Intending to update a method's settings but the old entry was not removed.","solutions":["Remove the duplicate method entry from the config string","Keep only one config per method with the desired header/message settings","Deduplicate method entries before setting the env var"],"exampleFix":"# before (duplicate method rule)\nexport GRPC_BINARY_LOG_FILTER=\"Foo/Bar{m:256},Foo/Bar{m:512}\"\n\n# after (single rule)\nexport GRPC_BINARY_LOG_FILTER=\"Foo/Bar{m:512}\"","handlingStrategy":"validation","validationCode":"// Validate for duplicate method rules\nfunc validateBinaryLogConfig(s string) error {\n    if s == \"\" {\n        return nil\n    }\n    seen := map[string]bool{}\n    for _, part := range strings.Split(s, \",\") {\n        part = strings.TrimSpace(part)\n        if strings.HasPrefix(part, \"-\") || strings.HasPrefix(part, \"*\") {\n            continue\n        }\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                if seen[part] {\n                    return fmt.Errorf(\"duplicate method rule for %q\", part)\n                }\n                seen[part] = true\n            }\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Deduplicate method entries when composing the filter string","Keep a single config per method with the final desired settings"],"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"}