{"record":{"id":"16ab697ec9094290","repo":"json-path/JsonPath","slug":"square-brackets-does-not-match-in-filter","errorCode":null,"errorMessage":"Square brackets does not match in filter ","messagePattern":"Square brackets does not match in filter ","errorType":"exception","errorClass":"InvalidPathException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java","lineNumber":362,"sourceCode":"        if(!boolValue.equals(\"true\") && !boolValue.equals(\"false\")){\n            throw new InvalidPathException(\"Expected boolean literal\");\n        }\n        filter.incrementPosition(boolValue.length());\n        logger.trace(\"BooleanLiteral from {} to {} -> [{}]\", begin, end, boolValue);\n\n        return ValueNode.createBooleanNode(boolValue);\n    }\n\n    private PathNode readPath() {\n        char previousSignificantChar = filter.previousSignificantChar();\n        int begin = filter.position();\n\n        filter.incrementPosition(1); //skip $ and @\n        while (filter.inBounds()) {\n            if (filter.currentChar() == OPEN_SQUARE_BRACKET) {\n                int closingSquareBracketIndex = filter.indexOfMatchingCloseChar(filter.position(), OPEN_SQUARE_BRACKET, CLOSE_SQUARE_BRACKET, true, false);\n                if (closingSquareBracketIndex == -1) {\n                    throw new InvalidPathException(\"Square brackets does not match in filter \" + filter);\n                } else {\n                    filter.setPosition(closingSquareBracketIndex + 1);\n                }\n            }\n            boolean closingFunctionBracket = (filter.currentChar() == CLOSE_PARENTHESIS && currentCharIsClosingFunctionBracket(begin));\n            boolean closingLogicalBracket  = (filter.currentChar() == CLOSE_PARENTHESIS && !closingFunctionBracket);\n\n            if (!filter.inBounds() || isRelationalOperatorChar(filter.currentChar()) || filter.currentChar() == SPACE || closingLogicalBracket) {\n                break;\n            } else {\n                filter.incrementPosition(1);\n            }\n        }\n\n        boolean shouldExists = !(previousSignificantChar == NOT);\n        CharSequence path = filter.subSequence(begin, filter.position());\n        return ValueNode.createPathNode(path, false, shouldExists);\n    }","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java#L344-L380","documentation":"Raised in FilterCompiler.readPath while scanning a path operand ($... or @...) inside a filter: the compiler found '[' in the path but never the matching ']' (or the brackets are improperly nested/escaped), so the bracket segment is unbalanced. The offending input is a filter path with an unclosed bracket, e.g. $.items[?(@.x == 1] or $store[0.","triggerScenarios":"Thrown at json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java:362 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Close the bracket segment with a matching ']', e.g. $.store[0] or $.items[?(@.x == 1)]","Check for brackets inside string literals within the filter that the scanner may treat as segment openers — quote/escape them correctly","Avoid mixing filter syntax with path syntax incorrectly; put operators only inside [?( ... )] segments","Pre-validate bracket balance in dynamically built path strings before calling JsonPath.compile/parse"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}