{"record":{"id":"6111f629f27e1397","repo":"grpc/grpc-java","slug":"illegal-log-config-pattern-6111f6","errorCode":null,"errorMessage":"Illegal log config pattern","messagePattern":"Illegal log config pattern","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"services/src/main/java/io/grpc/protobuf/services/BinlogHelper.java","lineNumber":734,"sourceCode":"     *\n     * <p>If the {@code logConfig} is null, the returned binlog will have a limit of\n     * Integer.MAX_VALUE.\n     */\n    @VisibleForTesting\n    @Nullable\n    static BinlogHelper createBinaryLog(BinaryLogSink sink, @Nullable String logConfig) {\n      if (logConfig == null) {\n        return new BinlogHelper(\n            new SinkWriterImpl(\n                sink, TimeProvider.SYSTEM_TIME_PROVIDER, Integer.MAX_VALUE, Integer.MAX_VALUE));\n      }\n      try {\n        final int maxHeaderBytes;\n        final int maxMsgBytes;\n        String[] parts = logConfig.split(\";\", 2);\n        if (parts.length == 2) {\n          if (!(parts[0].startsWith(\"h\") && parts[1].startsWith(\"m\"))) {\n            throw new IllegalArgumentException(\"Illegal log config pattern\");\n          }\n          maxHeaderBytes = optionalInt(parts[0].substring(1));\n          maxMsgBytes = optionalInt(parts[1].substring(1));\n        } else if (parts[0].startsWith(\"h\")) {\n          maxHeaderBytes = optionalInt(parts[0].substring(1));\n          maxMsgBytes = 0;\n        } else if (parts[0].startsWith(\"m\")) {\n          maxHeaderBytes = 0;\n          maxMsgBytes = optionalInt(parts[0].substring(1));\n        } else {\n          throw new IllegalArgumentException(\"Illegal log config pattern\");\n        }\n        return new BinlogHelper(\n            new SinkWriterImpl(\n                sink, TimeProvider.SYSTEM_TIME_PROVIDER, maxHeaderBytes, maxMsgBytes));\n      } catch (NumberFormatException e) {\n        throw new IllegalArgumentException(\"Illegal log config pattern\");\n      }","sourceCodeStart":716,"sourceCodeEnd":752,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/services/src/main/java/io/grpc/protobuf/services/BinlogHelper.java#L716-L752","documentation":"When parsing the binlog options inside braces, FactoryImpl requires that a two-part (split by ';') option string start with 'h' for the header limit and 'm' for the message limit. Anything else, e.g. 'x:1;m:2' or reversed order 'm:1;h:2', throws IllegalArgumentException('Illegal log config pattern').","triggerScenarios":"A config entry whose option string contains ';' but whose parts do not start with 'h' and 'm' respectively, e.g. 'svc/Method{m:100;h:2}' or 'svc/Method{x;h:2}'.","commonSituations":"Writing options in the wrong order (m before h), using unknown option prefixes, or typos like 'H:' (uppercase).","solutions":["Order options as header first then message: '{h:<bytes>;m:<bytes>}'","Use only 'h' and 'm' option prefixes, lowercase","If only one limit is needed, drop the ';' and use a single 'h:...' or 'm:...' option"],"exampleFix":"// before\n\"*{m:100;h:2}\"\n// after\n\"*{h:2;m:100}\"","handlingStrategy":"validation","validationCode":"String opts = entry.substring(entry.indexOf('{') + 1, entry.length() - 1);\nif (opts.contains(\";\")) {\n  String[] p = opts.split(\";\", 2);\n  if (!(p[0].startsWith(\"h\") && p[1].startsWith(\"m\"))) {\n    throw new IllegalStateException(\"Options must be h then m: \" + opts);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  BinlogHelper h = new BinlogHelper.FactoryImpl(sink, configStr);\n} catch (IllegalArgumentException e) {\n  // rewrite offending entry to {h:n;m:n} order\n}","preventionTips":["Always order options h before m","Use lowercase 'h'/'m' prefixes only","Prefer the canonical full form '{h:<n>;m:<n>}' in templates"],"tags":["grpc","binary-log","configuration","parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"64daddc1f3d1975670f769f3e97bde8b2ba32d25","analyzedAt":"2026-09-08T06:14:57.704Z","contentChangedAt":"2026-09-08T06:14:57.704Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}