Skip to content

50N00 internal error in SlottedRewriter for FOREACH + COUNT {} + UNION ALL query #13720

@zihaozeng0021

Description

@zihaozeng0021

Configuration

Neo4j Version: neo4j:latest (pulled 2025-11-27)

Operating System: WSL2 – Ubuntu 24.04.1 LTS

Installation Method: Docker (neo4j:latest)

API/Driver: cypher-shell inside container

More Info:

neo4j@neo4j> CALL dbms.components() YIELD name, edition, versions
             RETURN name, edition, versions;

+----------------------------------------------+
| name           | edition     | versions      |
+----------------------------------------------+
| "Neo4j Kernel" | "community" | ["2025.10.1"] |
| "Cypher"       | ""          | ["5", "25"]   |
+----------------------------------------------+

Steps to reproduce

  1. Start neo4j via Docker
docker run -d \
  --name neo4j \
  -p 7474:7474 -p 7687:7687 \
  -e NEO4J_AUTH=neo4j/test12345 \
  neo4j:latest
  1. Connect with cypher-shell
docker exec -it neo4j cypher-shell -u neo4j -p test12345
  1. Run the following query
MATCH (n)
DETACH DELETE n;

FOREACH (x IN [1] |
  CREATE
    k3 = (n)-[:R]->(:C {
      agg: COUNT {
        WITH DISTINCT *
        MATCH () WHERE false
        RETURN 1 AS v
        UNION ALL
        MATCH () WHERE false
        RETURN 2 AS v
      }
    })-[:R]->(n)
);

Expected behaviour

The query executes successfully, since all used features are documented as supported (FOREACH, COUNT subquery with UNION ALL, etc.).

Actual behaviour

The query fails with an internal processing error:

0 rows
ready to start consuming query after 2 ms, results consumed after another 0 ms
50N00: general processing exception - internal error. Internal exception raised SlottedRewriter$: Did not find `n` in the slot configuration of Projection (Id(17))

Key Points:

  1. The query fails with 50N00 internal error (SlottedRewriter$…), which indicates a server-side processing bug.
  2. If this combination is intentionally unsupported, I would at least expect a clear Neo.ClientError.* style message explaining the limitation, rather than an internal error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions