{"record":{"id":"92a64f0efd51aaf1","repo":"apache/hadoop","slug":"illegal-field-separator-separator","errorCode":null,"errorMessage":"Illegal field separator: ${separator}","messagePattern":"Illegal field separator: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/CallerContext.java","lineNumber":164,"sourceCode":"    }\n\n    public Builder(String context, String separator) {\n      if (isValid(context)) {\n        sb.append(context);\n      }\n      fieldSeparator = separator;\n      checkFieldSeparator(fieldSeparator);\n    }\n\n    /**\n     * Check whether the separator is legal.\n     * The illegal separators include '\\t', '\\n', '='.\n     * Throw IllegalArgumentException if the separator is Illegal.\n     * @param separator the separator of fields.\n     */\n    private void checkFieldSeparator(String separator) {\n      if (ILLEGAL_SEPARATORS.contains(separator)) {\n        throw new IllegalArgumentException(\"Illegal field separator: \"\n            + separator);\n      }\n    }\n\n    /**\n     * Whether the field is valid.\n     * @param field one of the fields in context.\n     * @return true if the field is not null or empty.\n     */\n    private boolean isValid(String field) {\n      return field != null && field.length() > 0;\n    }\n\n    public Builder setSignature(byte[] signature) {\n      if (signature != null && signature.length > 0) {\n        this.signature = Arrays.copyOf(signature, signature.length);\n      }\n      return this;","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/CallerContext.java#L146-L182","documentation":"CallerContext.Builder joins audit fields with a configurable separator, and rejects three separators that would corrupt the audit string: tab (\\t), newline (\\n), and equals (=). The separator comes from the Builder(String, String) overload or, in production, from the hadoop.caller.context.separator config (default '#'). Constructing the Builder with any illegal value throws this IllegalArgumentException.","triggerScenarios":"Setting hadoop.caller.context.separator to '=', a literal tab, or '\\n' (XML often encodes these as &amp;#9;/&amp;#10; and they arrive as real control characters); building CallerContext programmatically via new CallerContext.Builder(context, \"=\").","commonSituations":"Teams structuring caller contexts as key=value pairs and choosing '=' as the field separator, which collides with the reserved KEY_VALUE_SEPARATOR ':'-style semantics and audit parsing; YAML/XML configs where an escaped tab or newline slips into the value; migrating apps that used ad-hoc separators.","solutions":["Pick a legal separator such as '#' (the default) or '-'.","Audit the effective value: hadoop conf or conf.get(\"hadoop.caller.context.separator\").","In XML, avoid numeric character refs tricks that inject tab/newline into the property.","If you need key=value styling inside a field, use ':' (KEY_VALUE_SEPARATOR) within fields and keep the field separator '#'."],"exampleFix":"# before\n<property><name>hadoop.caller.context.separator</name><value>=</value></property>\nnew CallerContext.Builder(\"app\", conf); // throws: Illegal field separator: =\n\n# after\n<property><name>hadoop.caller.context.separator</name><value>#</value></property>\nnew CallerContext.Builder(\"app\", conf).add(\"op\", \"scan\");","handlingStrategy":"validation","validationCode":"String sep = conf.get(\"hadoop.caller.context.separator\", \"#\");\nif (\"\\t\".equals(sep) || \"\\n\".equals(sep) || \"=\".equals(sep)) {\n  throw new IllegalArgumentException(\"hadoop.caller.context.separator must not be tab, newline or '=': \" + sep);\n}","typeGuard":"static boolean isLegalCallerContextSeparator(String s) {\n  return s != null && !(\"\\t\".equals(s) || \"\\n\".equals(s) || \"=\".equals(s));\n}","tryCatchPattern":"try {\n  CallerContext context = new CallerContext.Builder(\"app\", conf).build();\n} catch (IllegalArgumentException e) {\n  // separator config is illegal; fall back to the default '#'\n  CallerContext context = new CallerContext.Builder(\"app\").build();\n}","preventionTips":["Leave hadoop.caller.context.separator at its default ('#') unless you have a reason.","Never encode key=value pairs with '=' as the field separator; use '#' or '-' between fields and ':' inside fields.","Add a startup assertion for the separator when apps build CallerContext from user-supplied config."],"tags":["hadoop","ipc","audit","caller-context","configuration","validation"],"backgroundTag":"invalid-configuration-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}