{"record":{"id":"dd1315750fc6334f","repo":"json-path/JsonPath","slug":"expected-value-list-node","errorCode":null,"errorMessage":"Expected value list node","messagePattern":"Expected value list node","errorType":"exception","errorClass":"InvalidPathException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/internal/filter/ValueNode.java","lineNumber":80,"sourceCode":"\n    public JsonNode asJsonNode() {\n        throw new InvalidPathException(\"Expected json node\");\n    }\n\n    public boolean isPredicateNode() {\n        return false;\n    }\n\n    public PredicateNode asPredicateNode() {\n        throw new InvalidPathException(\"Expected predicate node\");\n    }\n\n    public boolean isValueListNode() {\n        return false;\n    }\n\n    public ValueListNode asValueListNode() {\n        throw new InvalidPathException(\"Expected value list node\");\n    }\n\n    public boolean isNullNode() {\n        return false;\n    }\n\n    public NullNode asNullNode() {\n        throw new InvalidPathException(\"Expected null node\");\n    }\n\n    public UndefinedNode asUndefinedNode() {\n        throw new InvalidPathException(\"Expected undefined node\");\n    }\n\n    public boolean isUndefinedNode() {\n        return false;\n    }\n","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ValueNode.java#L62-L98","documentation":"ValueNode's base asValueListNode() throws InvalidPathException(\"Expected value list node\") when a node that is not a ValueListNode is cast via asValueListNode(). ValueListNode represents a list of value operands used by operators like in/contains/all (callers: evaluate, requiredValues, shouldContainAll, res, listNode). It is thrown when such an operator receives a single scalar node instead of a value-list operand.","triggerScenarios":"Using array operators (in, contains, all, size comparisons) where the operand list was not built as a ValueListNode — e.g. @.x in 'a' with a scalar instead of a list ['a','b'], or evaluating against a field that is a scalar rather than an array when the operator iterates values.","commonSituations":"Filters like $.items[?(@.tags in ['a','b'])] evaluated on records where tags is null or a single string instead of an array; mixing single-value and list operands in 'contains'/'in' checks.","solutions":["Provide the operand as a JSON array: $.items[?(@.tag in ['a','b'])]","Ensure the field being iterated (e.g. tags) is an array in the document; normalize scalars to single-element arrays before filtering","Use equality (==) instead of in/contains when the value is genuinely a scalar","Catch InvalidPathException and treat items with non-array fields as non-matching"],"exampleFix":"// before\n$.items[?(@.tag in 'a')]  // scalar operand, not a value list\n// after\n$.items[?(@.tag in ['a'])]","handlingStrategy":"validation","validationCode":"Object v = JsonPath.parse(json).read(\"$.item.tags\");\nif (v != null && !(v instanceof List)) throw new IllegalArgumentException(\"tags must be an array for in/contains operators\");","typeGuard":"static boolean isListOperand(Object o) { return o instanceof List; }","tryCatchPattern":"try {\n    return JsonPath.parse(json).read(\"$.items[?(@.tag in ['a','b'])]\");\n} catch (InvalidPathException e) {\n    return Collections.emptyList(); // non-list operand\n}","preventionTips":["Always pass array literals for in/contains operands: ['a','b']","Normalize scalar fields to single-element arrays before filtering","Use == for genuinely scalar comparisons instead of in/contains"],"tags":["jsonpath","filter","type-mismatch","value-list"],"backgroundTag":"type-mismatch","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"}