SET/REMOVE properties on an entity deleted earlier in the same query silently succeed
Neo4j version
Neo4j 2026.06.0 Community (docker image neo4j:2026.06.0-community). Identical behavior on 5.26.27 and 2026.05.0.
Environment
- Host OS: Linux x86_64
- Deployment: Docker, image
neo4j:2026.06.0-community(fresh container, no prior state) - Query interface: HTTP transaction API
- Query language: Cypher
Description
When a query deletes a node or relationship and a later clause references the same variable, property writes to that entity are silently accepted and reported as updates, even though the target has already been deleted and the writes have no persistent effect.
The decisive distinction is between target validation and expression evaluation. SET a.v = 99 completes successfully after a has been deleted, whereas SET a.v = a.v + 1 raises EntityNotFound while evaluating the right-hand side. This indicates that the deleted-entity condition is checked by the property-read path but not by the property-write target path.
Steps to reproduce
// A. Node property SET target after DELETE: silently succeeds (BUG)
CREATE (a:Oracle {v:1})
DELETE a WITH a
SET a.v = 99
RETURN 'done';
// B. Read of deleted property: raises an error (control)
CREATE (a:Oracle {v:1})
DELETE a WITH a
RETURN a.v;
// C. SET whose RHS reads the deleted property: raises an error (control)
CREATE (a:Oracle {v:1})
DELETE a WITH a
SET a.v = a.v + 1
RETURN 'done';
// D. Node property REMOVE target after DELETE: silently succeeds (BUG)
CREATE (a:Oracle {v:1})
DELETE a WITH a
REMOVE a.v
RETURN 'done';
// E. Relationship property SET target after DELETE: silently succeeds (BUG)
CREATE ()-[r:R {v:1}]->()
DELETE r WITH r
SET r.v = 99
RETURN 'done';
// F. Relationship property REMOVE target after DELETE: silently succeeds (BUG)
CREATE ()-[r:R {v:1}]->()
DELETE r WITH r
REMOVE r.v
RETURN 'done';Affected write paths
Silently accepted (no error, no warning; the operation is accepted and the entity remains deleted, so the property update has no persistent effect):
- Node property
SET - Node property
REMOVE - Relationship property
SET - Relationship property
REMOVE - Single and multiple property assignments (
SET a.v = 1, a.w = 2) DELETEandDETACH DELETEvariants
All reproduced 3/3 runs on 2026.06.0; same behavior on 5.26.27 and 2026.05.0, and on the slotted, pipelined, and parallel runtimes.
Controls and neighboring paths
| Path | Outcome (2026.06.0, 3/3 runs) |
|---|---|
Property read of the deleted entity (RETURN a.v) |
error Neo.ClientError.Statement.EntityNotFound |
Reading the deleted entity on the SET right-hand side (SET a.v = a.v + 1) |
error Neo.ClientError.Statement.EntityNotFound |
Right-hand side that loads the entity (SET a.v = size(labels(a))) |
error Neo.ClientError.Statement.EntityNotFound |
Right-hand side that only reads the stored identifier (SET a.v = elementId(a)) |
succeeds, update has no persistent effect |
Label mutation (SET a:Label, REMOVE a:Label) |
internal-style error Unable to load NODE (50N00) |
Returning the deleted entity (RETURN a) |
succeeds, yields an empty projection {} |
Repeating DELETE on the same entity |
silently tolerated |
The elementId(a) versus size(labels(a)) pair suggests that validation occurs when entity state is loaded, but not when only the stored identifier is accessed.
Version range
| Version | A SET silent |
B RETURN a.v error |
|---|---|---|
| 5.26.27 | yes (3/3) | yes (3/3) |
| 2026.05.0 | yes (3/3) | yes (3/3) |
| 2026.06.0 | yes (3/3) | yes (3/3) |
Behavior consistent across the tested range; not a regression within it (older versions untested).
Related issue
#13812 (open) covers deleted-entity reuse that raises errors with internal error quality: CREATE/MERGE patterns and label mutations produce Unable to load NODE (50N00). Its discussion treats property SET/REMOVE only as a control that does not raise an internal error; the silent acceptance of property writes is not raised there as a defect. This issue is that defect. Same deleted-entity lifecycle family, but a different observable failure and property-update operator path.
Expected behavior
SET and REMOVE should reject a property-update target that was deleted earlier in the same query, rather than reporting successful completion while applying no update.
A suitable outcome would be the same Neo.ClientError.Statement.EntityNotFound currently raised when reading a property from the deleted entity.
The issue is independent of cross-engine behavior: Neo4j already detects the deleted entity when evaluating a.v on the right-hand side, but does not perform an equivalent check when a is used as the target of SET or REMOVE. The Cypher manual states that deleted graph elements are no longer accessible.
Isolated recheck
Fresh containers for each version, no prior state. All six queries run 3 times each; deterministic. Runtime check: explicit CYPHER runtime = slotted / pipelined / parallel prefixes, isolated state per run, all three runtimes identical.
Supplementary query-statistics evidence strengthens the inconsistency. The query reports:
nodes_created: 1nodes_deleted: 1properties_set: 2
One property update comes from CREATE (a:Oracle {v:1}); the second is the SET a.v = 99 executed after DELETE a. Neo4j therefore counts the deleted-target SET as an applied update even though the target no longer exists after the query and no written property is observable.
Impact
An invalid use-after-delete query is reported as successfully completed even though the reported property update cannot have any persistent effect because its target has already been deleted. This can conceal query-generation and control-flow errors, particularly when an updating query returns normal result rows such as 'done'.
Source: neo4j/neo4j