Type predicate `LIST<ANY NOT NULL>` accepts lists that contain null
Reporter: ting668
Neo4j Version: 2026.08.1 (Community edition; also checked on 5.26.30, the current 5.26 LTS patch)
Operating System: Linux (WSL2), inside a Docker container
Installation Method: Docker image neo4j:2026.08.1
API/Driver: cypher-shell (Bolt, in-container)
Description
While testing Neo4j using an intuitive approach inspired by attribute constraints, I found that the type predicate LIST<ANY NOT NULL> accepts lists that contain null.
In the Cypher type system, LIST<ANY NOT NULL> denotes a list whose elements are all of type ANY and none of them is null; the NOT NULL modifier exists precisely to exclude null members. Accepting [null] and [1, null] against this predicate makes the NOT NULL modifier a no-op for ANY element types. Reading a missing property yields null, so the single-element list [n.m] is [null] on such nodes and the type predicate must reject it.
Steps to reproduce
Note: The queries below are a minimized, simplified example reproducing the bug.
Buggy query (no data needed):
RETURN [null] IS :: LIST<ANY NOT NULL> AS a,
[1, null] IS :: LIST<ANY NOT NULL> AS b;Expected behavior
A list containing null does not satisfy a NOT NULL element constraint, so both checks should return false:
a = FALSE, b = FALSEActual behavior
Both checks return true (observed on 2026.08.1 and 5.26.30 via cypher-shell):
a = TRUE, b = TRUEAs a control, the individual pieces behave correctly — a list without null satisfies the predicate:
RETURN [1] IS :: LIST<ANY NOT NULL> AS good;good = TRUEand plain LIST<ANY> has no null restriction, so null membership is accepted there — which is exactly what NOT NULL is supposed to add:
RETURN [null] IS :: LIST<ANY> AS anytype;anytype = TRUEThis also affects queries over stored data. Setup and buggy query:
CREATE (:N {uid:'bad'});
CREATE (:N {uid:'keep', m:1});
MATCH (n:N)
WHERE [n.m] IS :: LIST<ANY NOT NULL>
RETURN n.uid AS uid;Expected behavior: only the node whose m property is present should be returned, since [n.m] evaluates to [null] on the node with the missing property and must fail LIST<ANY NOT NULL>:
uid = "keep"Actual behavior: both nodes are returned — the node whose m is missing produces [null], which is wrongly accepted:
uid = "bad"
uid = "keep"This suggests that the nullability of the element type is not enforced when the type predicate checks list elements, so LIST<ANY NOT NULL> currently behaves the same as plain LIST<ANY>. Possibly related to #13819, which concerned NOT NULL list handling in a different code path (pattern-element type-expression validation short-circuiting) rather than the IS :: value predicate.
Source: neo4j/neo4j