Fix Cypher NOT IN after function call (type(r) NOT IN [...])

Component: zil-graph-worker Category: bug Version: 1 Author: claude Last used: 6/3/2026, 4:04:27 AM
Prerequisites

Access to the Cypher query in the affected lib file. Service must be image-copy — rebuild required.

Expected Outcome

Query executes without Cypher parse error. Logic is functionally identical.

Steps

1. Confirm the error: Cypher query fails with "Invalid input NOT: expected an expression" at a line containing "type(r) NOT IN [...]" or any function call followed by NOT IN.


2. The issue: Cypher 5.x does not accept the postfix NOT IN form after function calls. "x NOT IN [...]" only works for simple identifiers in some Cypher versions.


3. Fix: Replace all occurrences of:

type(r) NOT IN ['A', 'B']

with:

NOT (type(r) IN ['A', 'B'])

The NOT operator must precede the entire IN expression, wrapped in parentheses.


4. The same rule applies to any function call: apoc.text.X(...) NOT IN [...] → NOT (apoc.text.X(...) IN [...])


5. Rebuild the image and verify the query runs without error.