toeverything/AFFiNE · error · Error

Parent folder not found

Error message

Parent folder not found

What it means

A parent-validation guard in createLink: it looks up parentId in the folders table and requires it to exist and have type 'folder' before creating a doc/tag/collection link under it. It fires when a link is requested under a parent id that is missing or refers to a non-folder node (e.g. another link); the faulting input is the parentId argument.

Source

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

        return false; // loop detected
      }
      history.add(current);
      if (current === ancestorId) {
        return true;
      }
    }
    return false;
  }

  createLink(
    parentId: string,
    type: 'doc' | 'tag' | 'collection',
    nodeId: string,
    index: string
  ) {
    const parent = this.dbService.db.folders.get(parentId);
    if (parent === null || parent.type !== 'folder') {
      throw new Error('Parent folder not found');
    }

    this.dbService.db.folders.create({
      parentId,
      type,
      data: nodeId,
      index: index,
    });
  }

  renameNode(nodeId: string, name: string) {
    const node = this.dbService.db.folders.get(nodeId);
    if (node === null) {
      throw new Error('Node not found');
    }
    if (node.type !== 'folder') {
      throw new Error('Cannot rename non-folder node');
    }

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Ensure the parent folder exists before creating/moving a node.
  2. Refresh the folder tree and retry.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown when creating a link or folder under a parent whose folder record is missing in the folders DB or is not of type folder.

Common situations: Occurs when adding a doc/tag/collection link or subfolder into a folder that was deleted or desynced. Refresh the workspace and pick an existing folder as the target.


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