{"record":{"id":"43b48f8b6b4ebfc5","repo":"toeverything/AFFiNE","slug":"parent-folder-not-found","errorCode":null,"errorMessage":"Parent folder not found","messagePattern":"Parent folder not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/frontend/core/src/modules/organize/stores/folder.ts","lineNumber":55,"sourceCode":"        return false; // loop detected\n      }\n      history.add(current);\n      if (current === ancestorId) {\n        return true;\n      }\n    }\n    return false;\n  }\n\n  createLink(\n    parentId: string,\n    type: 'doc' | 'tag' | 'collection',\n    nodeId: string,\n    index: string\n  ) {\n    const parent = this.dbService.db.folders.get(parentId);\n    if (parent === null || parent.type !== 'folder') {\n      throw new Error('Parent folder not found');\n    }\n\n    this.dbService.db.folders.create({\n      parentId,\n      type,\n      data: nodeId,\n      index: index,\n    });\n  }\n\n  renameNode(nodeId: string, name: string) {\n    const node = this.dbService.db.folders.get(nodeId);\n    if (node === null) {\n      throw new Error('Node not found');\n    }\n    if (node.type !== 'folder') {\n      throw new Error('Cannot rename non-folder node');\n    }","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/core/src/modules/organize/stores/folder.ts#L37-L73","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the parent folder exists before creating/moving a node.","Refresh the folder tree and retry."],"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-14T00:17:10.932Z"}