{"record":{"id":"c0ee4bf705483b9a","repo":"apache/beam","slug":"illegal-octal-digit","errorCode":null,"errorMessage":"illegal octal digit","messagePattern":"illegal octal 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":381,"sourceCode":"      return ch;\n    }\n\n    private static int unescapeHex(String str) {\n      int ch = 0;\n      for (int i = 0; i < str.length(); i++) {\n        ch = 16 * ch + hexValue(str.charAt(i));\n      }\n      if (!Character.isValidCodePoint(ch)) {\n        throw new IllegalArgumentException(\"illegal codepoint\");\n      }\n      return ch;\n    }\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":363,"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#L363-L398","documentation":"octalValue maps a single character to its octal value (0–7). Any character outside '0'–'7' — such as '8', '9', or a letter — encountered in an octal escape sequence throws IllegalArgumentException(\"illegal octal digit\"). The escape grammar only permits octal digits in that position.","triggerScenarios":"A backslash followed by digits including 8 or 9, e.g. \"a\\98b\", parsed by unescapeOctal via unescapeFieldName — '9' is not an octal digit.","commonSituations":"Decimal escapes mistakenly written where octal escapes are expected (\\9 meaning character 9); copy-pasted escapes from languages with decimal escape semantics; typos in hand-written escaped field names.","solutions":["Use only digits 0–7 in octal escape sequences.","Convert decimal escapes to octal form (e.g. \\9 -> \\11) or switch to a \\uXXXX hex escape.","Remove the backslash if the sequence was not intended as an escape.","Escape field names programmatically with the library's escaping logic rather than by hand."],"exampleFix":"// before\nString field = \"item\\98desc\"; // 9 and 8 are not octal digits\n// after\nString field = \"item\\u0038desc\"; // hex escape for the intended character","handlingStrategy":"validation","validationCode":"// Java: check all octal escape digits are 0-7\nstatic boolean octalDigitsValid(String name) {\n  java.util.regex.Matcher m =\n      java.util.regex.Pattern.compile(\"\\\\\\\\([^uU0-7])(.*)\").matcher(name);\n  return !m.find();\n}","typeGuard":null,"tryCatchPattern":"try {\n  String decoded = QueryUtils.unescaped(fieldName);\n} catch (IllegalArgumentException e) {\n  LOG.warn(\"Non-octal digit in escape sequence: %s\", fieldName, e);\n}","preventionTips":["Remember escapes are octal: only digits 0–7 are legal.","Use \\uXXXX escapes to avoid octal/decimal confusion.","Never hand-write escaped field names; generate them with tooling."],"tags":["firestore","field-name","escaping","java","apache-beam"],"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"}