{"record":{"id":"154dd90cc1dd8db4","repo":"json-path/JsonPath","slug":"pattern-not-closed-expected","errorCode":null,"errorMessage":"Pattern not closed. Expected ","messagePattern":"Pattern not closed\\. Expected ","errorType":"exception","errorClass":"InvalidPathException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java","lineNumber":295,"sourceCode":"    private int endOfFlags(int position) {\n        int endIndex = position;\n        char[] currentChar = new char[1];\n        while (filter.inBounds(endIndex)) {\n            currentChar[0] = filter.charAt(endIndex);\n            if (PatternFlag.parseFlags(currentChar) > 0) {\n                endIndex++;\n                continue;\n            }\n            break;\n        }\n        return endIndex;\n    }\n\n    private PatternNode readPattern() {\n        int begin = filter.position();\n        int closingIndex = filter.nextIndexOfUnescaped(PATTERN);\n        if (closingIndex == -1) {\n            throw new InvalidPathException(\"Pattern not closed. Expected \" + PATTERN + \" in \" + filter);\n        } else {\n            if (filter.inBounds(closingIndex+1)) {\n                int endFlagsIndex = endOfFlags(closingIndex + 1);\n                if (endFlagsIndex > closingIndex) {\n                    CharSequence flags = filter.subSequence(closingIndex + 1, endFlagsIndex);\n                    closingIndex += flags.length();\n                }\n            }\n            filter.setPosition(closingIndex + 1);\n        }\n        CharSequence pattern = filter.subSequence(begin, filter.position());\n        logger.trace(\"PatternNode from {} to {} -> [{}]\", begin, filter.position(), pattern);\n        return ValueNode.createPatternNode(pattern);\n    }\n\n    private StringNode readStringLiteral(char endChar) {\n        int begin = filter.position();\n","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java#L277-L313","documentation":"Raised in FilterCompiler.readPattern when compiling an inline regex literal (e.g. /pattern/flags) in a JSON Path filter expression: the scanner reached the end of the path without finding the unescaped closing '/' that terminates the pattern, so the literal is unterminated. It is a strict syntax guard — the offending input is a filter path containing a '/' that opens a regex but never closes it (or the closer is escaped, as in \\/).","triggerScenarios":"Thrown at json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java:295 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Close the regex literal with an unescaped '/' in the filter expression, e.g. @.name =~ /^ab.*c$/","If the pattern must contain a literal '/', escape it as \\/ so it is not treated as the closing delimiter","If the value is not meant to be a regex, replace the '~=' operator and slash-delimited form with a plain string comparison","Validate the filter path string (balanced, unescaped delimiters) before passing it to 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"}