{"record":{"id":"319930b3138e47b8","repo":"apache/beam","slug":"illegal-hex-digit","errorCode":null,"errorMessage":"illegal hex digit","messagePattern":"illegal hex digit","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/QueryUtils.java","lineNumber":393,"sourceCode":"    }\n\n    private static int octalValue(char d) {\n      if (d >= '0' && d <= '7') {\n        return d - '0';\n      } else {\n        throw new IllegalArgumentException(\"illegal octal digit\");\n      }\n    }\n\n    private static int hexValue(char d) {\n      if (d >= '0' && d <= '9') {\n        return d - '0';\n      } else if (d >= 'a' && d <= 'f') {\n        return 10 + d - 'a';\n      } else if (d >= 'A' && d <= 'F') {\n        return 10 + d - 'A';\n      } else {\n        throw new IllegalArgumentException(\"illegal hex digit\");\n      }\n    }\n  }\n}\n","sourceCodeStart":375,"sourceCodeEnd":398,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/QueryUtils.java#L375-L398","documentation":"hexValue maps a single character to its hexadecimal value (0–9, a–f, A–F). Any other character found in a \\u or \\U escape sequence throws IllegalArgumentException(\"illegal hex digit\"). Hex escapes in Firestore field names must consist exclusively of hex digits.","triggerScenarios":"A \\u or \\U escape containing a non-hex character, e.g. \"\\u00G1\" or \"\\U0000 041\" (embedded space), decoded by unescapeFieldName through unescapeHex.","commonSituations":"Hand-written escapes with typos ('O' instead of '0', 'g' instead of '9'); escapes truncated or mangled by string formatting; placeholders like \\uXXXX left unexpanded in generated code.","solutions":["Replace every non-hex character inside the escape with a valid hex digit (0-9, a-f, A-F).","Expand placeholder escapes (e.g. \\uXXXX) with the actual code point before use.","Generate escaped names with tooling instead of typing them manually.","Validate the escaped field name with a regex like \\\\u[0-9a-fA-F]{4} before passing it in."],"exampleFix":"// before\nString field = \"\\u00G1x\"; // 'G' is not a hex digit\n// after\nString field = \"\\u00A1x\"; // valid hex digits","handlingStrategy":"validation","validationCode":"// Java: ensure \\u/\\U escapes contain only hex digits\nstatic boolean hexDigitsValid(String name) {\n  java.util.regex.Matcher m =\n      java.util.regex.Pattern.compile(\"\\\\\\\\[uU]([0-9a-fA-F]*)\") .matcher(name);\n  int end = 0;\n  while (m.find(end)) {\n    if (m.group(1).length() == 0) return false; // placeholder like \\uXXXX\n    end = m.end();\n  }\n  return name.indexOf(\"\\\\u\") < 0 || end > 0;\n}","typeGuard":null,"tryCatchPattern":"try {\n  String decoded = QueryUtils.unescaped(fieldName);\n} catch (IllegalArgumentException e) {\n  LOG.warn(\"Non-hex digit in unicode escape: %s\", fieldName, e);\n}","preventionTips":["Expand placeholder escapes (\\uXXXX) before using generated field names.","Check for typos like 'O' vs '0' or 'G' in hand-written escapes.","Regex-validate escaped names before querying Firestore."],"tags":["firestore","field-name","escaping","hex","java"],"backgroundTag":"invalid-argument-format","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}