{"record":{"id":"23f04296ac3fac65","repo":"toeverything/AFFiNE","slug":"link-not-found","errorCode":null,"errorMessage":"Link not found","messagePattern":"Link not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/frontend/core/src/modules/organize/stores/folder.ts","lineNumber":121,"sourceCode":"      if (!current) {\n        continue;\n      }\n      if (current.type !== 'folder') {\n        this.dbService.db.folders.delete(current.id);\n      } else {\n        const children = this.dbService.db.folders.find({\n          parentId: current.id,\n        });\n        stack.push(...children);\n        this.dbService.db.folders.delete(current.id);\n      }\n    }\n  }\n\n  removeLink(linkId: string) {\n    const link = this.dbService.db.folders.get(linkId);\n    if (link === null || link.type === 'folder') {\n      throw new Error('Link not found');\n    }\n    this.dbService.db.folders.delete(linkId);\n  }\n\n  moveNode(nodeId: string, parentId: string | null, index: string) {\n    const node = this.dbService.db.folders.get(nodeId);\n    if (node === null) {\n      throw new Error('Node not found');\n    }\n\n    if (parentId) {\n      if (nodeId === parentId) {\n        throw new Error('Cannot move a node to itself');\n      }\n      if (this.isAncestor(parentId, nodeId)) {\n        throw new Error('Cannot move a node to its descendant');\n      }\n      const parent = this.dbService.db.folders.get(parentId);","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/core/src/modules/organize/stores/folder.ts#L103-L139","documentation":"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.","triggerScenarios":"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.","commonSituations":"Triggered when removing a link entry that no longer exists or is actually a folder. Refresh the sidebar and retry removing the correct item.","solutions":["Verify the link node exists; refresh the tree.","Recreate the link if it was removed."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}