{"record":{"id":"8f630edf273f0689","repo":"json-path/JsonPath","slug":"not-enough-predicates-supplied-for-filter-at-po","errorCode":null,"errorMessage":"Not enough predicates supplied for filter [] at position ","messagePattern":"Not enough predicates supplied for filter \\[\\] at position ","errorType":"exception","errorClass":"InvalidPathException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java","lineNumber":430,"sourceCode":"        }\n        char nextSignificantChar = path.nextSignificantChar(questionmarkIndex);\n        if (nextSignificantChar != CLOSE_SQUARE_BRACKET && nextSignificantChar != COMMA) {\n            return false;\n        }\n\n        int expressionBeginIndex = path.position() + 1;\n        int expressionEndIndex = path.nextIndexOf(expressionBeginIndex, CLOSE_SQUARE_BRACKET);\n\n        if (expressionEndIndex == -1) {\n            return false;\n        }\n\n        String expression = path.subSequence(expressionBeginIndex, expressionEndIndex).toString();\n\n        String[] tokens = expression.split(\",\");\n\n        if (filterStack.size() < tokens.length) {\n            throw new InvalidPathException(\"Not enough predicates supplied for filter [\" + expression + \"] at position \" + path.position());\n        }\n\n        Collection<Predicate> predicates = new ArrayList<Predicate>();\n        for (String token : tokens) {\n            token = token != null ? token.trim() : null;\n            if (!\"?\".equals(token == null ? \"\" : token)) {\n                throw new InvalidPathException(\"Expected '?' but found \" + token);\n            }\n            predicates.add(filterStack.pop());\n        }\n\n        appender.appendPathToken(PathTokenFactory.createPredicatePathToken(predicates));\n\n        path.setPosition(expressionEndIndex + 1);\n\n        return path.currentIsTail() || readNextToken(appender);\n    }\n","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java#L412-L448","documentation":"InvalidPathException thrown by readPlaceholderToken when a filter path uses positional '?' placeholders (e.g. [?,?]) but fewer predicates were pushed onto filterStack than there are comma-separated placeholder tokens. Each '?' must correspond to a predicate supplied earlier via Filter.predicate(...).","triggerScenarios":"Calling JsonPath.query(path, predicate) with fewer predicate arguments than '?' placeholders in the path, e.g. path \"$..book[?(@.a)][?,?]\" style patterns with only one predicate supplied for two '?' tokens.","commonSituations":"API migration where predicates were removed from the call but the path string kept multiple placeholders; building paths dynamically and miscounting placeholders.","solutions":["Supply one predicate (Filter.filter(...) or Criteria) per '?' placeholder in the path","Remove extra '?' tokens from the path that have no matching predicate","Count '?' occurrences in the path and assert the predicate array length matches before querying"],"exampleFix":"// before\nJsonPath.query(\"$..book[?,?]\", filterA)\n// after\nJsonPath.query(\"$..book[?,?]\", filterA, filterB)","handlingStrategy":"validation","validationCode":"long placeholders = path.chars().filter(c -> c == '?').count();\nif (placeholders != predicates.size()) {\n    throw new IllegalArgumentException(\"Path has \" + placeholders + \" placeholders but \" + predicates.size() + \" predicates supplied\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return JsonPath.query(path, predicates.toArray());\n} catch (InvalidPathException e) {\n    if (e.getMessage().startsWith(\"Not enough predicates\")) {\n        throw new IllegalArgumentException(\"Predicate count mismatch for path: \" + path);\n    }\n    throw e;\n}","preventionTips":["Generate the '?' placeholders and the predicate list together in one builder method","Assert placeholder count equals predicate count before calling JsonPath","When editing queries, update path and predicates in the same change"],"tags":["json-path","filter","predicate","invalid-path"],"backgroundTag":"missing-required-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"}