{"record":{"id":"3816b08b96147859","repo":"grpc/grpc-go","slug":"conflicting-service-rules-for-service-v-found","errorCode":null,"errorMessage":"conflicting service rules for service %v found","messagePattern":"conflicting service rules for service (.+?) found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/binarylog/binarylog.go","lineNumber":126,"sourceCode":"func newEmptyLogger() *logger {\n\treturn &logger{}\n}\n\n// Set method logger for \"*\".\nfunc (l *logger) setDefaultMethodLogger(ml *MethodLoggerConfig) error {\n\tif l.config.All != nil {\n\t\treturn fmt.Errorf(\"conflicting global rules found\")\n\t}\n\tl.config.All = ml\n\treturn nil\n}\n\n// Set method logger for \"service/*\".\n//\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}","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/internal/binarylog/binarylog.go#L108-L144","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Remove the duplicate service rule from the config string","Merge the header/message settings into a single entry for that service","Deduplicate service entries programmatically before setting the env var"],"exampleFix":"# before (duplicate service rule)\nexport GRPC_BINARY_LOG_FILTER=\"Foo/*{h:256},Foo/*{m:512}\"\n\n# after (single merged rule)\nexport GRPC_BINARY_LOG_FILTER=\"Foo/*{h:256;m:512}\"","handlingStrategy":"validation","validationCode":"// Validate for duplicate service rules\nfunc validateBinaryLogConfig(s string) error {\n    if s == \"\" {\n        return nil\n    }\n    services := 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        // Check if it's a service rule (ends with /*)\n        if idx := strings.Index(part, \"/\"); idx >= 0 {\n            svc := part[:idx]\n            method := part[idx+1:]\n            // Strip suffix braces from method for comparison\n            if braceIdx := strings.Index(method, \"{\"); braceIdx >= 0 {\n                method = method[:braceIdx]\n            }\n            if method == \"*\" {\n                if services[svc] {\n                    return fmt.Errorf(\"duplicate service rule for %q\", svc)\n                }\n                services[svc] = true\n            }\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Deduplicate service entries when composing the filter string","Use a config builder or template that prevents duplicates","Review the filter string for repeated service names before deployment"],"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"}