toeverything/AFFiNE · error · Error

Root node can only have folders

Error message

Root node can only have folders

What it means

A root-level invariant guard in moveNode: when parentId is null the node is being moved to the root of the organize tree, and only folders may exist at root level. It fires when a doc/tag/collection link is moved to the root (no parent) — links must always live inside a folder.

Source

Thrown at packages/frontend/core/src/modules/organize/stores/folder.ts:145

    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

  1. Only create folders at the root of the organize tree.
  2. Move non-folder nodes into a folder instead.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown by moveNode when moving a non-folder node (doc/tag/collection link) to the root (parentId null), since the root level of the organize tree only accepts folders.

Common situations: Occurs when dragging a doc or tag link to the top level of the sidebar tree. Place links inside a folder instead of at root.


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/c1f378942d57a547. Report an issue: GitHub.