db.index.vector.queryNodes leaks an internal ArithmeticException when numberOfNearestNeighbours exceeds Integer.MAX_VALUE
Author: hkjiang26Created Aug 30, 2026Updated Sep 14, 2026
LabelsbugGithub Issue
Neo4j Version: neo4j:2026.07.1 (Docker)
Installation Method: Docker
API: Cypher (Bolt / cypher-shell) - built-in procedure
Steps to reproduce
- Create a vector index and one node:
CREATE VECTOR INDEX vecIdx FOR (n:Doc) ON (n.emb)
OPTIONS {indexConfig: {`vector.dimensions`: 2, `vector.similarity_function`: 'cosine'}};
CREATE (:Doc {emb: [1.0, 2.0]});- Query with a neighbor count above
Integer.MAX_VALUE:
CALL db.index.vector.queryNodes('vecIdx', 2147483648, [1.0, 2.0]) YIELD node, score
RETURN node, scoreControl: the same call with k = 2 returns the node with score 1.0.
Expected behavior
A clean client-side argument validation error.
Actual behavior
52U00: procedure exception - custom procedure execution error cause. Execution of the procedure db.index.vector.queryNodes() failed due to java.lang.ArithmeticException: integer overflow.The procedure parameter is declared Long and only validated as > 0; Math.toIntExact(numberOfNearestNeighbours) in VectorIndexProcedures.queryNodeVectorIndex* (lines 161/184/206/229) throws an uncaught ArithmeticException that surfaces as an internal procedure error. A user-typed integer is enough - no data or index state is required beyond any existing vector index.
Source: neo4j/neo4j