{"record":{"id":"69a1782ec374ee6a","repo":"apache/beam","slug":"could-not-resolve-empty-field-path","errorCode":null,"errorMessage":"Could not resolve empty field path","messagePattern":"Could not resolve empty field path","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":173,"sourceCode":"      return null;\n    }\n    return findMapValue(segments, value.getMapValue().getFieldsMap());\n  }\n\n  private static class OrderByFieldPath implements Comparable<OrderByFieldPath> {\n\n    private static final String UNQUOTED_NAME_REGEX_STRING = \"([a-zA-Z_][a-zA-Z_0-9]*)\";\n    private static final String QUOTED_NAME_REGEX_STRING = \"(`(?:[^`\\\\\\\\]|(?:\\\\\\\\.))+`)\";\n    // After each segment follows a dot and more characters, or the end of the string.\n    private static final Pattern FIELD_PATH_SEGMENT_REGEX =\n        Pattern.compile(\n            String.format(\n                \"(?:%s|%s)(\\\\..+|$)\", UNQUOTED_NAME_REGEX_STRING, QUOTED_NAME_REGEX_STRING),\n            Pattern.DOTALL);\n\n    public static OrderByFieldPath fromString(String fieldPath) {\n      if (fieldPath.isEmpty()) {\n        throw new IllegalArgumentException(\"Could not resolve empty field path\");\n      }\n      String originalString = fieldPath;\n      List<String> segments = new ArrayList<>();\n      while (!fieldPath.isEmpty()) {\n        Matcher segmentMatcher = FIELD_PATH_SEGMENT_REGEX.matcher(fieldPath);\n        boolean foundMatch = segmentMatcher.lookingAt();\n        if (!foundMatch) {\n          throw new IllegalArgumentException(\"OrderBy field path was malformed\");\n        }\n        String fieldName;\n        if ((fieldName = segmentMatcher.group(1)) != null) {\n          segments.add(fieldName);\n        } else if ((fieldName = segmentMatcher.group(2)) != null) {\n          String unescaped = unescapeFieldName(fieldName.substring(1, fieldName.length() - 1));\n          segments.add(unescaped);\n        } else {\n          throw new IllegalArgumentException(\"OrderBy field path was malformed\");\n        }","sourceCodeStart":155,"sourceCodeEnd":191,"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#L155-L191","documentation":"QueryUtils.OrderByFieldPath.fromString() throws this IllegalArgumentException when asked to parse an empty string as a Firestore order-by field path. A field path must have at least one segment; an empty value cannot be resolved to any document field.","triggerScenarios":"Calling OrderByFieldPath.fromString(\"\") or passing an empty/blank order-by field name into a Firestore query builder that constructs an OrderBy from a string.","commonSituations":"An ORDER BY / sort option is configured from user input or config where the field name is missing or trimmed to empty, e.g. an empty query parameter, YAML key, or CLI flag defaulting to \"\".","solutions":["Ensure the order-by field path string is non-empty before calling fromString","If the sort field is optional, skip adding the OrderBy entirely instead of passing an empty string","Trim user/config input and reject blanks with a clear upstream validation error"],"exampleFix":"// before\nString sortField = config.getOrDefault(\"sortField\", \"\");\nqueryBuilder.addOrderBy(OrderByFieldPath.fromString(sortField));\n// after\nString sortField = config.getOrDefault(\"sortField\", \"\").trim();\nif (!sortField.isEmpty()) {\n  queryBuilder.addOrderBy(OrderByFieldPath.fromString(sortField));\n}","handlingStrategy":"validation","validationCode":"if (fieldPath == null || fieldPath.trim().isEmpty()) {\n  throw new IllegalArgumentException(\"order-by field path must be a non-empty string\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  OrderByFieldPath p = OrderByFieldPath.fromString(fieldPath);\n} catch (IllegalArgumentException e) {\n  LOG.warn(\"Invalid order-by field path '{}' : {}\", fieldPath, e.getMessage());\n}","preventionTips":["Treat sort/order-by field names as required config and fail fast at config-load time","Trim and check emptiness of user-supplied field names before building queries"],"tags":["java","apache-beam","firestore","empty-input","field-path"],"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"}