{"record":{"id":"99d546e8881e86f8","repo":"apache/beam","slug":"illegal-trailing-backslash","errorCode":null,"errorMessage":"illegal trailing backslash","messagePattern":"illegal trailing backslash","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":272,"sourceCode":"      for (int i = 0; i < fieldName.length(); i++) {\n        char c = fieldName.charAt(i);\n        // Roughly speaking, there are 4 cases we care about:\n        //   - carriage returns: \\r and \\r\\n\n        //   - unescaped quotes: `\n        //   - non-escape sequences\n        //   - escape sequences\n        if (c == '`') {\n          throw new IllegalArgumentException(\"quoted identifier cannot contain unescaped quote\");\n        } else if (c == '\\r') {\n          buf.append('\\n');\n          // Convert '\\r\\n' into '\\n'\n          if (i + 1 < fieldName.length() && fieldName.charAt(i + 1) == '\\n') {\n            i++;\n          }\n        } else if (c != '\\\\') {\n          buf.append(c);\n        } else if (i + 1 >= fieldName.length()) {\n          throw new IllegalArgumentException(\"illegal trailing backslash\");\n        } else {\n          i++;\n          switch (fieldName.charAt(i)) {\n            case 'a':\n              buf.appendCodePoint(Ascii.BEL); // \"Alert\" control character\n              break;\n            case 'b':\n              buf.append('\\b');\n              break;\n            case 'f':\n              buf.append('\\f');\n              break;\n            case 'n':\n              buf.append('\\n');\n              break;\n            case 'r':\n              buf.append('\\r');\n              break;","sourceCodeStart":254,"sourceCodeEnd":290,"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#L254-L290","documentation":"unescapeFieldName() throws this IllegalArgumentException when the quoted identifier's content ends with a lone backslash that starts an escape sequence but has no following character. A trailing \\ cannot be interpreted as any valid escape, so the identifier is rejected.","triggerScenarios":"A quoted segment like `abc\\` where the final character is a backslash not followed by any escape character (a, b, f, n, r, t, v, \\, `, 0-3, x, u, U).","commonSituations":"Config strings where a trailing backslash was intended as a literal (e.g. Windows-style name) and not doubled; string escaping done twice or truncated by upstream tooling.","solutions":["Remove the trailing backslash if it is accidental","Escape it as \\\\ so it represents a literal backslash","Validate the quoted identifier has no trailing lone backslash before parsing"],"exampleFix":"// before\nOrderByFieldPath.fromString(\"doc.`path\\\\`\"); // ends with single \\\\\n// after\nOrderByFieldPath.fromString(\"doc.`path\\\\\\\\`\");","handlingStrategy":"validation","validationCode":"public static boolean endsWithLoneBackslash(String quotedContent) {\n  int bs = 0;\n  for (int i = quotedContent.length() - 1; i >= 0 && quotedContent.charAt(i) == '\\\\'; i--) bs++;\n  return bs % 2 == 1;\n}","typeGuard":null,"tryCatchPattern":"try {\n  OrderByFieldPath p = OrderByFieldPath.fromString(path);\n} catch (IllegalArgumentException e) {\n  LOG.warn(\"Trailing backslash in quoted identifier '{}'\", path);\n}","preventionTips":["Double every intended-literal backslash (\\\\) when authoring quoted identifiers","Check config strings for trailing backslashes after editing, especially Windows-derived paths"],"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"}