toeverything/AFFiNE · error · Error
Cannot move a node to itself
Error message
Cannot move a node to itself
What it means
A cycle guard in moveNode: when moving nodeId under a non-null parentId, the first check rejects the degenerate case where the node would become its own parent (nodeId === parentId). It fires when a move request designates the node itself as the new parent folder.
Source
Thrown at packages/frontend/core/src/modules/organize/stores/folder.ts:134
}
removeLink(linkId: string) {
const link = this.dbService.db.folders.get(linkId);
if (link === null || link.type === 'folder') {
throw new Error('Link not found');
}
this.dbService.db.folders.delete(linkId);
}
moveNode(nodeId: string, parentId: string | null, index: string) {
const node = this.dbService.db.folders.get(nodeId);
if (node === null) {
throw new Error('Node not found');
}
if (parentId) {
if (nodeId === parentId) {
throw new Error('Cannot move a node to itself');
}
if (this.isAncestor(parentId, nodeId)) {
throw new Error('Cannot move a node to its descendant');
}
const parent = this.dbService.db.folders.get(parentId);
if (parent === null || parent.type !== 'folder') {
throw new Error('Parent folder not found');
}
} else {
if (node.type !== 'folder') {
throw new Error('Root node can only have folders');
}
}
this.dbService.db.folders.update(nodeId, {
parentId,
index,
});
}View on GitHub (pinned to b4c8548c09)
Solutions
- Choose a different destination folder.
- Guard the move operation against identical source and target.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown by moveNode when nodeId equals parentId, i.e. a drag-and-drop or move operation targets the node itself as its new parent.
Common situations: Happens when a user drags a folder onto itself in the organize tree. Drop the node onto a different destination folder.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/fe84dcc07e46989c.
Report an issue: GitHub.