#13940·neo4j

SlottedRewriter loses a projected alias with duplicated nested COLLECT after NEXT USE

Author: YGY-001Created Aug 23, 2026Updated Sep 3, 2026
Labelsbugcypherteam-cypherGithub Issue

Environment

  • Neo4j 2026.07.1 (neo4j:2026.07)
  • Cypher 25
  • Reproduces on a fresh neo4j database
  • Reproduces with both runtime=slotted and runtime=pipelined

Reproduction

Place this file at import/fuzz.csv:

alpha,beta
one,two

Run the following query:

cypher
CYPHER runtime=slotted
UNWIND [1] AS x
RETURN x LIMIT 1
NEXT USE neo4j
INSERT (:N)
LET a = 1, b = []
RETURN a, x, 1 AS c, 1 AS alias6,
  COLLECT {
    WITH 1 AS alias27, 1 AS alias26
    LIMIT 4
    WHERE EXISTS {
      LOAD CSV WITH HEADERS FROM 'file:///fuzz.csv' AS alias28
      ORDER BY alias28
    }
    RETURN max('rQAm') AS alias29 SKIP 7 LIMIT 0
  } AS alias30
ORDER BY alias6 DESC,
  COLLECT {
    WITH 1 AS alias27, 1 AS alias26
    LIMIT 4
    WHERE EXISTS {
      LOAD CSV WITH HEADERS FROM 'file:///fuzz.csv' AS alias28
      ORDER BY alias28
    }
    RETURN max('rQAm') AS alias29 SKIP 7 LIMIT 0
  } DESC,
  alias30 DESC

Actual result

The server raises an internal error instead of returning a normal result:

50N00: Internal exception raised SlottedRewriter$:
Did not find alias6 in slot configuration of Projection (Id(...))

runtime=pipelined also fails in the same SlottedRewriter phase. Removing NEXT USE, the ORDER BY alias28 inside LOAD CSV, or the duplicated nested COLLECT from the top-level ORDER BY makes the query complete.

Expected result

The query should either return its result or report a normal Cypher semantic error. A valid query should not produce an internal slot-rewriter exception.