{"record":{"id":"32e04c55081be5a7","repo":"json-path/JsonPath","slug":"empty-properties","errorCode":null,"errorMessage":"Empty properties","messagePattern":"Empty properties","errorType":"exception","errorClass":"InvalidPathException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/internal/path/PropertyPathToken.java","lineNumber":38,"sourceCode":"import com.jayway.jsonpath.internal.PathRef;\nimport com.jayway.jsonpath.internal.Utils;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport static com.jayway.jsonpath.internal.Utils.onlyOneIsTrueNonThrow;\n\n/**\n *\n */\npublic class PropertyPathToken extends PathToken {\n\n    private final List<String> properties;\n    private final String stringDelimiter;\n\n    public PropertyPathToken(List<String> properties, char stringDelimiter) {\n        if (properties.isEmpty()) {\n            throw new InvalidPathException(\"Empty properties\");\n        }\n        this.properties = properties;\n        this.stringDelimiter = Character.toString(stringDelimiter);\n    }\n\n    public List<String> getProperties() {\n        return properties;\n    }\n\n    public boolean singlePropertyCase() {\n        return properties.size() == 1;\n    }\n\n    public boolean multiPropertyMergeCase() {\n        return isLeaf() && properties.size() > 1;\n    }\n\n    public boolean multiPropertyIterationCase() {","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/internal/path/PropertyPathToken.java#L20-L56","documentation":"PropertyPathToken represents a property access (e.g. $.foo) in a compiled JSON path. The constructor rejects an empty list of properties because a path token must reference at least one property name; an empty token would make the compiled path meaningless. This is thrown at path-compilation time, before any document is evaluated.","triggerScenarios":"Calling Filter.path(...) or internal APIs that build a PropertyPathToken with an empty List<String> properties, e.g. new PropertyPathToken(Collections.emptyList(), '\\u0000') or mis-using internal path-builder APIs (PathCompiler) with no property segments.","commonSituations":"Building paths programmatically from user input or config where the property name is an empty string or filtered out; writing custom PathToken/predicate code against jayway internals; splitting a path string on '.' when the string starts or ends with a dot, producing empty segments.","solutions":["Ensure the property list passed to PropertyPathToken (or the path string given to JsonPath.compile) contains at least one non-empty property name","Trim/validate user-supplied path strings and reject or skip empty segments before compiling","If generating paths dynamically, guard: if (properties.isEmpty()) throw new IllegalArgumentException(...) or skip token creation","Use the public JsonPath.compile/PathCompiler APIs instead of instantiating PropertyPathToken directly"],"exampleFix":"// before\nList<String> props = Arrays.asList(raw.split(\"\\\\.\"));\nPropertyPathToken token = new PropertyPathToken(props, '\\'');\n// after\nList<String> props = Arrays.stream(raw.split(\"\\\\.\"))\n        .map(String::trim)\n        .filter(s -> !s.isEmpty())\n        .collect(Collectors.toList());\nif (props.isEmpty()) throw new IllegalArgumentException(\"path has no properties\");\nPropertyPathToken token = new PropertyPathToken(props, '\\'');","handlingStrategy":"validation","validationCode":"List<String> props = Arrays.asList(segment.split(\"\\\\.\"));\nif (props.stream().anyMatch(String::isEmpty)) throw new IllegalArgumentException(\"empty property in path\");","typeGuard":"boolean valid = properties != null && !properties.isEmpty();","tryCatchPattern":null,"preventionTips":["Never build path tokens from unvalidated user input","Filter empty segments after splitting path strings","Prefer public JsonPath.compile over internal token classes"],"tags":["json-path","invalid-path","path-compilation"],"backgroundTag":"empty-required-field","analyzedSha":"62a4c9f0f65ba3f625aa0867d64c528ba72d09ec","analyzedAt":"2026-09-11T11:36:00.448Z","contentChangedAt":"2026-09-11T11:36:00.448Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}