{"record":{"id":"eb88d4d9fb5af539","repo":"json-path/JsonPath","slug":"expected-offsetdatetime-node","errorCode":null,"errorMessage":"Expected offsetDateTime node","messagePattern":"Expected offsetDateTime node","errorType":"exception","errorClass":"InvalidPathException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/internal/filter/ValueNode.java","lineNumber":113,"sourceCode":"    public boolean isUndefinedNode() {\n        return false;\n    }\n\n    public boolean isClassNode() {\n        return false;\n    }\n\n    public ClassNode asClassNode() {\n        throw new InvalidPathException(\"Expected class node\");\n    }\n\n    //workaround for issue: https://github.com/json-path/JsonPath/issues/613\n    public boolean isOffsetDateTimeNode(){\n        return false;\n    }\n\n    public OffsetDateTimeNode asOffsetDateTimeNode(){\n        throw new InvalidPathException(\"Expected offsetDateTime node\");\n    }\n\n\n    private static boolean isPath(Object o) {\n        if(o == null || !(o instanceof String)){\n            return false;\n        }\n        String str = o.toString().trim();\n        if (str.length() <= 0) {\n            return false;\n        }\n        char c0 = str.charAt(0);\n        if(c0 == '@' || c0 == '$'){\n            try {\n                PathCompiler.compile(str);\n                return true;\n            } catch(Exception e){\n                return false;","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ValueNode.java#L95-L131","documentation":"ValueNode's base asOffsetDateTimeNode() throws InvalidPathException(\"Expected offsetDateTime node\") when called on a node that is not an OffsetDateTimeNode. This is the workaround added for GitHub issue json-path/JsonPath#613, enabling date comparisons in filters (e.g. @.date < 2020-01-01T00:00Z). The error means a date-comparison filter received a non-date operand node.","triggerScenarios":"Date-comparison filters where the operand is not an OffsetDateTimeNode — e.g. the compared field is a plain string not parseable/handled as OffsetDateTime, the value wasn't routed through createOffsetDateTimeNode, or the JsonPath version predates/is inconsistent with the issue-613 workaround. Raised from evaluate on date comparisons.","commonSituations":"Comparing ISO date strings stored in JSON with datetime literals in filters on a JsonPath version lacking the #613 fix (dates treated as plain strings); fields formatted with non-ISO date strings the OffsetDateTime parser rejects; mixing Date and OffsetDateTime representations.","solutions":["Upgrade json-path to a version containing the issue #613 OffsetDateTime workaround so date literals become OffsetDateTimeNode operands","Store dates in ISO-8601 offset format (e.g. 2020-01-01T00:00:00+00:00) in documents and filters so they parse as OffsetDateTime","Compare lexicographically as ISO strings instead of using date operators, or pre-filter in Java code by parsing dates yourself","Catch InvalidPathException and fall back to string/date parsing in application code"],"exampleFix":"// before\n$.orders[?(@.created < 2020-01-01)] // non-ISO literal, no OffsetDateTimeNode on old versions\n// after\n$.orders[?(@.created < 2020-01-01T00:00:00+00:00)] // ISO-8601 with offset, on json-path with #613 fix","handlingStrategy":"validation","validationCode":"String raw = JsonPath.parse(json).read(\"$.order.created\");\nOffsetDateTime.parse(raw); // throws DateTimeParseException if not ISO-8601 with offset\nif (raw.contains(\" \") || !raw.matches(\".*([+-]\\d\\d:\\d\\d|Z)$\")) throw new IllegalArgumentException(\"created must be ISO-8601 with offset\");","typeGuard":"static boolean isIsoOffsetDate(String s) { try { OffsetDateTime.parse(s); return true; } catch (DateTimeParseException e) { return false; } }","tryCatchPattern":"try {\n    return JsonPath.parse(json).read(\"$.orders[?(@.created < 2020-01-01T00:00:00+00:00)]\");\n} catch (InvalidPathException e) {\n    // fall back to parsing dates in Java and filtering manually\n    return manualDateFilter(json);\n}","preventionTips":["Upgrade json-path to a release containing the issue #613 OffsetDateTime workaround","Store and compare dates only in ISO-8601 offset format","Never mix java.util.Date with JsonPath date filters; convert to OffsetDateTime first","Test date filters against your actual document date formats"],"tags":["jsonpath","filter","date","type-mismatch"],"backgroundTag":"invalid-date-format","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"}