{"record":{"id":"e1a3f3d1ab62f46c","repo":"json-path/JsonPath","slug":"path-must-not-end-with-a","errorCode":null,"errorMessage":"Path must not end with a '.","messagePattern":"Path must not end with a '\\.","errorType":"exception","errorClass":"InvalidPathException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java","lineNumber":168,"sourceCode":"                }\n                return true;\n            default:\n                if (!readPropertyOrFunctionToken(appender)) {\n                    fail(\"Could not parse token starting at position \" + path.position());\n                }\n                return true;\n        }\n    }\n\n    //\n    // . and ..\n    //\n    private boolean readDotToken(PathTokenAppender appender) {\n        if (path.currentCharIs(PERIOD) && path.nextCharIs(PERIOD)) {\n            appender.appendPathToken(PathTokenFactory.crateScanToken());\n            path.incrementPosition(2);\n        } else if (!path.hasMoreCharacters()) {\n            throw new InvalidPathException(\"Path must not end with a '.\");\n        } else {\n            path.incrementPosition(1);\n        }\n        if(path.currentCharIs(PERIOD)){\n            throw new InvalidPathException(\"Character '.' on position \" + path.position() + \" is not valid.\");\n        }\n        return readNextToken(appender);\n    }\n\n    //\n    // fooBar or fooBar()\n    //\n    private boolean readPropertyOrFunctionToken(PathTokenAppender appender) {\n        if (path.currentCharIs(OPEN_SQUARE_BRACKET) || path.currentCharIs(WILDCARD) || path.currentCharIs(PERIOD) || path.currentCharIs(SPACE)) {\n            return false;\n        }\n        int startPosition = path.position();\n        int readPosition = startPosition;","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java#L150-L186","documentation":"readDotToken rejects a path that terminates immediately after a dot, i.e. the path ends with a trailing '.' and no property follows. A dot must be followed by a property name, wildcard, or another token; otherwise compilation fails with InvalidPathException.","triggerScenarios":"Paths like `$.store.`, `$..`, or dynamically built paths where a trailing separator was appended in a loop (`\"$.\" + String.join(\".\", parts)` with empty parts).","commonSituations":"Programmatic path assembly with joins producing trailing dots; users typing a path in a UI and leaving a trailing period; copy-paste truncation.","solutions":["Remove the trailing '.' from the path string.","When building paths programmatically, strip trailing separators: `path.replaceAll(\"\\\\.$\", \"\")` or join without a trailing delimiter.","Validate the path (e.g. try JsonPath.compile in a try-catch) before using it on documents."],"exampleFix":"// before\nString p = \"$.a.b.\"; // trailing dot\nJsonPath.read(json, p);\n// after\nString p = \"$.a.b\";\nJsonPath.read(json, p);","handlingStrategy":"validation","validationCode":"String sanitizePath(String p) {\n    return p == null ? null : p.replaceAll(\"\\\\.+$\", \"\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return JsonPath.read(json, path);\n} catch (InvalidPathException e) {\n    throw new IllegalArgumentException(\"Malformed path (trailing dot?): \" + path, e);\n}","preventionTips":["Strip trailing dots when assembling paths programmatically.","Avoid naive string concatenation with '.' separators; join parts and validate.","Compile paths in tests before production use."],"tags":["json-path","invalid-path","syntax","compiler"],"backgroundTag":"invalid-path-syntax","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"}