{"record":{"id":"868b77412146179a","repo":"grpc/grpc-go","slug":"invalid-header-message-length-config-q-v","errorCode":null,"errorMessage":"invalid header/message length config: %q, %v","messagePattern":"invalid header/message length config: %q, (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/binarylog/env_config.go","lineNumber":104,"sourceCode":"\t// \"*{h:256;m:256}\"\n\tif config[0] == '*' {\n\t\thdr, msg, err := parseHeaderMessageLengthConfig(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 err := l.setDefaultMethodLogger(&MethodLoggerConfig{Header: hdr, Message: msg}); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid config: %v\", err)\n\t\t}\n\t\treturn nil\n\t}\n\n\ts, m, suffix, err := parseMethodConfigAndSuffix(config)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid config: %q, %v\", config, err)\n\t}\n\thdr, msg, err := parseHeaderMessageLengthConfig(suffix)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid header/message length config: %q, %v\", suffix, err)\n\t}\n\tif m == \"*\" {\n\t\tif err := l.setServiceMethodLogger(s, &MethodLoggerConfig{Header: hdr, Message: msg}); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid config: %v\", err)\n\t\t}\n\t} else {\n\t\tif err := l.setMethodMethodLogger(s+\"/\"+m, &MethodLoggerConfig{Header: hdr, Message: msg}); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid config: %v\", err)\n\t\t}\n\t}\n\treturn nil\n}\n\nconst (\n\t// TODO: this const is only used by env_config now. But could be useful for\n\t// other config. Move to binarylog.go if necessary.\n\tmaxUInt = ^uint64(0)\n","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/internal/binarylog/env_config.go#L86-L122","documentation":"Returned by fillMethodLoggerWithConfigString when parseHeaderMessageLengthConfig fails on the suffix of a method or service entry (env_config.go:102-104). The suffix (e.g., '{h:256;m:512}') extracted from the entry must match one of the three recognized patterns: {h}, {h:N}, {m}, {m:N}, {h;m}, or {h:N;m:N}. The %q is the suffix string; %v is the parse error. This differs from error 276 in that it applies to method/service entries, not the global '*' rule, and uses a different error prefix ('invalid header/message length config').","triggerScenarios":"A method or service entry in GRPC_BINARY_LOG_FILTER with a malformed length suffix, e.g., 'Foo/Bar{invalid}', 'Foo/Bar{h:abc}' (non-numeric), 'Foo/Bar{x:256}' (unknown key), or 'Foo/Bar{}'. The suffix must match headerConfigRegexp, messageConfigRegexp, or headerMessageConfigRegexp.","commonSituations":"Typos in the header/message length specification. Using unsupported keys (only 'h' and 'm' are valid). Non-numeric values where ParseUint expects decimal integers.","solutions":["Use valid suffix formats: '{h:256}', '{m:512}', '{h:256;m:512}', '{h}', '{m}', or omit the suffix for full logging","Ensure only 'h' (header) and 'm' (message) keys are used","Ensure numeric values are decimal integers parseable by strconv.ParseUint"],"exampleFix":"# before (malformed length suffix on method entry)\nexport GRPC_BINARY_LOG_FILTER=\"Foo/Bar{h:abc}\"\n\n# after (valid numeric header length)\nexport GRPC_BINARY_LOG_FILTER=\"Foo/Bar{h:256}\"","handlingStrategy":"validation","validationCode":"// Validate header/message length suffix on method/service entries\nvar lengthSuffixRe = regexp.MustCompile(`^\\{(?:(?:h(?::\\d+)?)?(?:;m(?::\\d+)?)?|m(?::\\d+)?)\\}$`)\n\nfunc validateLengthSuffix(entry string) error {\n    braceStart := strings.Index(entry, \"{\")\n    if braceStart < 0 {\n        return nil // no suffix, valid\n    }\n    suffix := entry[braceStart:]\n    if !lengthSuffixRe.MatchString(suffix) {\n        return fmt.Errorf(\"invalid length suffix %q; use {h:N}, {m:N}, {h:N;m:N}, {h}, or {m}\", suffix)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only 'h' (header) and 'm' (message) keys in length suffixes","Ensure numeric values are decimal integers parseable by strconv.ParseUint","Test the suffix format against the recognized patterns before deploying"],"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"}