{"record":{"id":"2a6330d893ffd1ba","repo":"apache/beam","slug":"illegal-unicode-escape-sequence","errorCode":null,"errorMessage":"illegal unicode escape sequence","messagePattern":"illegal unicode 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":334,"sourceCode":"              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              }\n              buf.appendCodePoint(unescapeHex(fieldName.substring(i, i + 4)));\n              i += 4;\n              break;\n            case 'U':\n              i++;\n              if (i + 8 > fieldName.length()) {\n                throw new IllegalArgumentException(\"illegal unicode escape sequence\");\n              }\n              buf.appendCodePoint(unescapeHex(fieldName.substring(i, i + 8)));\n              i += 8;\n              break;\n            default:\n              throw new IllegalArgumentException(\"illegal escape\");\n          }\n        }\n      }\n      return buf.toString();","sourceCodeStart":316,"sourceCodeEnd":352,"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#L316-L352","documentation":"unescapeFieldName() handles \\u (4 hex digits) and \\U (8 hex digits) unicode escapes; if fewer than the required digits remain after the u/U it throws this IllegalArgumentException. The unicode escape is truncated so the quoted identifier cannot be decoded.","triggerScenarios":"A quoted identifier containing \\u with fewer than 4 hex digits remaining (e.g. `caf\\u0`) or \\U with fewer than 8 (e.g. `\\U0001F60` at end of segment).","commonSituations":"Emoji/special-character field names encoded with unicode escapes that got truncated by string limits, logging redaction, or manual editing of config.","solutions":["Supply all required hex digits (4 for \\u, 8 for \\U)","Use literal UTF-8 characters in the field name instead of escapes where possible","Validate the full escape sequence exists before parsing the field path"],"exampleFix":"// before\nOrderByFieldPath.fromString(\"doc.`caf\\\\u0`\"); // truncated unicode escape\n// after\nOrderByFieldPath.fromString(\"doc.`caf\\\\u00e9`\");","handlingStrategy":"validation","validationCode":"public static boolean hasCompleteUnicodeEscapes(String s) {\n  java.util.regex.Matcher m4 = Pattern.compile(\"\\\\\\\\u([0-9A-Fa-f]{0,4})\").matcher(s);\n  while (m4.find()) if (m4.group(1).length() < 4) return false;\n  java.util.regex.Matcher m8 = Pattern.compile(\"\\\\\\\\U([0-9A-Fa-f]{0,8})\").matcher(s);\n  while (m8.find()) if (m8.group(1).length() < 8) return false;\n  return true;\n}","typeGuard":null,"tryCatchPattern":"try {\n  OrderByFieldPath p = OrderByFieldPath.fromString(path);\n} catch (IllegalArgumentException e) {\n  LOG.warn(\"Incomplete unicode escape in '{}'\", path);\n}","preventionTips":["Use literal UTF-8 characters in identifiers instead of unicode escapes where possible","Generate \\uXXXX (4 digits) and \\UXXXXXXXX (8 digits) with String.format to avoid truncation","Run escape-completeness validation on user-supplied field paths before query construction"],"tags":["java","apache-beam","firestore","field-path","escaping","unicode"],"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-14T21:17:11.552Z"}