{"record":{"id":"c7ca4f35a6cd0f95","repo":"apache/beam","slug":"quoted-identifier-cannot-be-empty","errorCode":null,"errorMessage":"quoted identifier cannot be empty","messagePattern":"quoted identifier cannot be empty","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":251,"sourceCode":"\n    @Override\n    public int compareTo(OrderByFieldPath other) {\n      // Inspired by com.google.cloud.firestore.FieldPath.\n      int length = Math.min(this.getSegments().size(), other.getSegments().size());\n      for (int i = 0; i < length; i++) {\n        byte[] thisField = this.getSegments().get(i).getBytes(StandardCharsets.UTF_8);\n        byte[] otherField = other.getSegments().get(i).getBytes(StandardCharsets.UTF_8);\n        int cmp = UnsignedBytes.lexicographicalComparator().compare(thisField, otherField);\n        if (cmp != 0) {\n          return cmp;\n        }\n      }\n      return Integer.compare(this.getSegments().size(), other.getSegments().size());\n    }\n\n    private static String unescapeFieldName(String fieldName) {\n      if (fieldName.isEmpty()) {\n        throw new IllegalArgumentException(\"quoted identifier cannot be empty\");\n      }\n      StringBuilder buf = new StringBuilder();\n      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 != '\\\\') {","sourceCodeStart":233,"sourceCodeEnd":269,"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#L233-L269","documentation":"unescapeFieldName() validates the inner content of a backtick-quoted Firestore identifier; if the quoted content is empty (``) it throws this IllegalArgumentException. Firestore identifiers must contain at least one character even when quoted.","triggerScenarios":"Parsing a field path whose segment is an empty backtick pair, e.g. fromString(\"``\") or fromString(\"a.``.b\") — the quoted identifier has no content to unescape.","commonSituations":"Copy/paste errors leaving `` in sort field config, template/interpolation that produced an empty field name inside backticks (e.g. `\"` + field + `\"` where field is empty).","solutions":["Replace the empty quoted segment with the actual field name","If the segment is dynamic, validate the interpolated field name is non-empty before building the path","Remove the empty segment entirely if it is not needed"],"exampleFix":"// before\nString path = \"user.`\" + subField + \"`.email\"; // subField == \"\"\n// after\nif (subField == null || subField.isEmpty()) {\n  throw new IllegalArgumentException(\"subField must be non-empty\");\n}\nString path = \"user.`\" + subField + \"`.email\";","handlingStrategy":"validation","validationCode":"public static boolean hasNonEmptyQuotedSegments(String path) {\n  java.util.regex.Matcher m = Pattern.compile(\"`([^`]*)`\").matcher(path);\n  while (m.find()) {\n    if (m.group(1).isEmpty()) return false;\n  }\n  return true;\n}","typeGuard":null,"tryCatchPattern":"try {\n  OrderByFieldPath p = OrderByFieldPath.fromString(path);\n} catch (IllegalArgumentException e) {\n  LOG.warn(\"Empty quoted identifier in field path '{}'\", path, e);\n}","preventionTips":["Validate interpolated field names are non-empty before embedding in backticks","Reject template output containing `` during config validation"],"tags":["java","apache-beam","firestore","field-path","quoted-identifier","empty-input"],"backgroundTag":"empty-required-field","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"}