{"record":{"id":"6af754fb70d50473","repo":"grpc/grpc-go","slug":"empty-string-is-not-a-valid-method-binary-logging","errorCode":null,"errorMessage":"empty string is not a valid method binary logging config","messagePattern":"empty string is not a valid method binary logging config","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/binarylog/env_config.go","lineNumber":65,"sourceCode":"\t\treturn nil\n\t}\n\tl := newEmptyLogger()\n\tmethods := strings.Split(s, \",\")\n\tfor _, method := range methods {\n\t\tif err := l.fillMethodLoggerWithConfigString(method); err != nil {\n\t\t\tgrpclogLogger.Warningf(\"failed to parse binary log config: %v\", err)\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn l\n}\n\n// fillMethodLoggerWithConfigString parses config, creates TruncatingMethodLogger and adds\n// it to the right map in the logger.\nfunc (l *logger) fillMethodLoggerWithConfigString(config string) error {\n\t// \"\" is invalid.\n\tif config == \"\" {\n\t\treturn errors.New(\"empty string is not a valid method binary logging config\")\n\t}\n\n\t// \"-service/method\", blacklist, no * or {} allowed.\n\tif config[0] == '-' {\n\t\ts, m, suffix, err := parseMethodConfigAndSuffix(config[1:])\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid config: %q, %v\", config, err)\n\t\t}\n\t\tif m == \"*\" {\n\t\t\treturn fmt.Errorf(\"invalid config: %q, %v\", config, \"* not allowed in blacklist config\")\n\t\t}\n\t\tif suffix != \"\" {\n\t\t\treturn fmt.Errorf(\"invalid config: %q, %v\", config, \"header/message limit not allowed in blacklist config\")\n\t\t}\n\t\tif err := l.setBlacklist(s + \"/\" + m); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid config: %v\", err)\n\t\t}\n\t\treturn nil","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/internal/binarylog/env_config.go#L47-L83","documentation":"Returned by fillMethodLoggerWithConfigString when a single comma-separated segment of the binary-log config string is empty. NewLoggerFromConfigString splits the config by commas and processes each part; an empty part (e.g., from a trailing comma or double comma) is not a valid method pattern. The empty config string itself (\"\") returns a nil logger and does not reach this function, so this error specifically fires for empty segments within a non-empty config.","triggerScenarios":"Setting GRPC_BINARY_LOG_FILTER to a value with a trailing comma (e.g., Foo/*,) or double comma (e.g., Foo/*,,Foo/Bar), or calling NewLoggerFromConfigString with such a string. Each empty segment triggers the error, which causes the entire logger to be discarded (returns nil).","commonSituations":"Operators edit the GRPC_BINARY_LOG_FILTER env var and accidentally introduce stray commas. Config-management tooling concatenates filter segments with commas and produces a trailing comma. The resulting nil logger silently disables binary logging, which is hard to notice without checking logs for the warning.","solutions":["Remove trailing or duplicate commas from the binary log filter string.","Validate the config string before applying it: split by comma and ensure no empty segments.","Check gRPC warning logs ('failed to parse binary log config') if binary logging appears inactive."],"exampleFix":"# before\nGRPC_BINARY_LOG_FILTER=\"Foo/*,\" # trailing comma → error, logging disabled\n# after\nGRPC_BINARY_LOG_FILTER=\"Foo/*\" # valid","handlingStrategy":"validation","validationCode":"// Validate the binary log filter string before applying:\nfor _, part := range strings.Split(filter, \",\") {\n    if part == \"\" {\n        return fmt.Errorf(\"binary log filter has an empty segment (check trailing/double commas): %q\", filter)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid trailing and double commas in GRPC_BINARY_LOG_FILTER.","Validate filter strings before setting the env var.","Check gRPC warning logs ('failed to parse binary log config') if logging is unexpectedly disabled."],"tags":["go","grpc","binarylog","config","validation"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}