{"record":{"id":"d8cd711b41822196","repo":"json-path/JsonPath","slug":"criteria-can-not-be-null","errorCode":null,"errorMessage":"Criteria can not be null","messagePattern":"Criteria can not be null","errorType":"validation","errorClass":"InvalidPathException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/Criteria.java","lineNumber":471,"sourceCode":"     */\n    public Criteria matches(Predicate p) {\n        this.criteriaType = RelationalOperator.MATCHES;\n        this.right = new PredicateNode(p);\n        return this;\n    }\n\n    /**\n     * Parse the provided criteria\n     *\n     * Deprecated use {@link Filter#parse(String)}\n     *\n     * @param criteria\n     * @return a criteria\n     */\n    @Deprecated\n    public static Criteria parse(String criteria) {\n        if(criteria == null){\n            throw new InvalidPathException(\"Criteria can not be null\");\n        }\n        String[] split = criteria.trim().split(\" \");\n        if(split.length == 3){\n            return create(split[0], split[1], split[2]);\n        } else if(split.length == 1){\n            return create(split[0], \"EXISTS\", \"true\");\n        } else {\n            throw new InvalidPathException(\"Could not parse criteria\");\n        }\n    }\n\n    /**\n     * Creates a new criteria\n     * @param left path to evaluate in criteria\n     * @param operator operator\n     * @param right expected value\n     * @return a new Criteria\n     */","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/Criteria.java#L453-L489","documentation":"The deprecated Criteria.parse(String) helper throws InvalidPathException when handed a null criteria string. It requires a non-null string it can split on spaces into path/operator/value parts, so null input is rejected immediately.","triggerScenarios":"Criteria.parse(null) — typically when the criteria string comes from configuration, a request parameter, or user input that was never populated.","commonSituations":"Legacy code still using the deprecated string-based filter builder where a config key or query parameter is missing, so null flows into parse().","solutions":["Migrate off the deprecated Criteria.parse(String) to Criteria.create(path, operator, value) or Filter.where(...).","Guard the input: throw a clear validation error or default before calling parse.","Fix the configuration/parameter source that yields null.","Trim/validate user-supplied criteria strings before building filters."],"exampleFix":"// before\nCriteria c = Criteria.parse(config.get(\"filter\"));\n// after\nString filter = config.get(\"filter\");\nif (filter == null) throw new IllegalArgumentException(\"filter config is required\");\nCriteria c = Criteria.parse(filter);","handlingStrategy":"type-guard","validationCode":"Objects.requireNonNull(criteria, \"criteria must not be null\");","typeGuard":"if (criteria == null) { throw new IllegalArgumentException(\"criteria required\"); }","tryCatchPattern":"try {\n    Criteria c = Criteria.parse(criteria);\n} catch (InvalidPathException e) {\n    throw new IllegalArgumentException(\"Bad criteria: \" + criteria, e);\n}","preventionTips":["Validate inputs before building filters.","Prefer Criteria.where(...)/Filter APIs over deprecated string parsing.","Default null criteria to a no-op Filter instead of parsing."],"tags":["jsonpath","filter","null","deprecated"],"backgroundTag":"null-argument","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"}