{"record":{"id":"3c0174e3325b7c19","repo":"apache/beam","slug":"illegal-octal-escape-sequence","errorCode":null,"errorMessage":"illegal octal escape sequence","messagePattern":"illegal octal escape sequence","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":317,"sourceCode":"              break;\n            case '\\\\':\n              buf.append('\\\\');\n              break;\n            case '\\'':\n              buf.append('\\'');\n              break;\n            case '\"':\n              buf.append('\\\"');\n              break;\n            case '`':\n              buf.append('`');\n              break;\n            case '0':\n            case '1':\n            case '2':\n            case '3':\n              if (i + 3 > fieldName.length()) {\n                throw new IllegalArgumentException(\"illegal octal escape sequence\");\n              }\n              buf.appendCodePoint(unescapeOctal(fieldName.substring(i, i + 3)));\n              i += 3;\n              break;\n            case 'x':\n            case 'X':\n              i++;\n              if (i + 2 > fieldName.length()) {\n                throw new IllegalArgumentException(\"illegal hex escape sequence\");\n              }\n              buf.appendCodePoint(unescapeHex(fieldName.substring(i, i + 2)));\n              i += 2;\n              break;\n            case 'u':\n              i++;\n              if (i + 4 > fieldName.length()) {\n                throw new IllegalArgumentException(\"illegal unicode escape sequence\");\n              }","sourceCodeStart":299,"sourceCodeEnd":335,"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#L299-L335","documentation":"unescapeFieldName() processes \\0 through \\3 octal escape sequences that must be followed by exactly two more characters forming a 3-digit octal code; if fewer than 3 characters remain it throws this IllegalArgumentException. The escape sequence is truncated, so the identifier is invalid.","triggerScenarios":"A quoted identifier ending with an incomplete octal escape, e.g. `a\\10` (only 2 chars after the backslash) or `\\0` at the very end of the segment.","commonSituations":"Programmatically generated identifiers with escape sequences cut off by length limits or string truncation; hand-written escapes where a digit was dropped.","solutions":["Complete the octal escape with all three digits, e.g. \\101 for 'A'","Remove the truncated escape if the character was not intended","Use \\xNN or \\uNNNN escapes instead for clarity and fixed length"],"exampleFix":"// before\nOrderByFieldPath.fromString(\"doc.`a\\\\10`\"); // truncated octal\n// after\nOrderByFieldPath.fromString(\"doc.`a\\\\101`\");","handlingStrategy":"validation","validationCode":"public static boolean hasCompleteEscapes(String s) {\n  for (int i = 0; i < s.length(); i++) {\n    if (s.charAt(i) == '\\\\') {\n      if (i + 1 >= s.length()) return false;\n      char c = s.charAt(++i);\n      int need = (c >= '0' && c <= '3') ? 2 : (c == 'x' || c == 'X') ? 2 : (c == 'u') ? 4 : (c == 'U') ? 8 : 0;\n      if (i + need >= s.length()) return false;\n      i += need;\n    }\n  }\n  return true;\n}","typeGuard":null,"tryCatchPattern":"try {\n  OrderByFieldPath p = OrderByFieldPath.fromString(path);\n} catch (IllegalArgumentException e) {\n  LOG.warn(\"Incomplete escape sequence in '{}'\", path);\n}","preventionTips":["Generate escapes with fixed-width helpers (String.format(\"\\\\\\\\%03o\", cp), \\\\\\\\u%04x)","Avoid truncating identifier strings that may contain escape sequences"],"tags":["java","apache-beam","firestore","field-path","escaping"],"backgroundTag":"invalid-escape-sequence","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}