toeverything/AFFiNE · error · Error

Link not found

Error message

Link not found

What it means

A lookup/type guard in removeLink: it fetches linkId and requires the record to exist and NOT be a folder (links are doc/tag/collection entries). It fires when a link removal is requested for an id that is missing or designates a folder — use removeFolder for folders; the faulting input is the linkId argument.

Source

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

      if (!current) {
        continue;
      }
      if (current.type !== 'folder') {
        this.dbService.db.folders.delete(current.id);
      } else {
        const children = this.dbService.db.folders.find({
          parentId: current.id,
        });
        stack.push(...children);
        this.dbService.db.folders.delete(current.id);
      }
    }
  }

  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);

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Verify the link node exists; refresh the tree.
  2. Recreate the link if it was removed.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown by removeLink when the linkId is absent from the folders DB or points to a folder node rather than a doc/tag/collection link.

Common situations: Triggered when removing a link entry that no longer exists or is actually a folder. Refresh the sidebar and retry removing the correct item.


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