{"record":{"id":"a5e32667f4a2e1b3","repo":"toeverything/AFFiNE","slug":"folder-not-found","errorCode":null,"errorMessage":"Folder not found","messagePattern":"Folder not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/frontend/core/src/modules/organize/stores/folder.ts","lineNumber":98,"sourceCode":"    if (parentId) {\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\n    return this.dbService.db.folders.create({\n      parentId: parentId,\n      type: 'folder',\n      data: name,\n      index: index,\n    }).id;\n  }\n\n  removeFolder(folderId: string) {\n    const info = this.dbService.db.folders.get(folderId);\n    if (info === null || info.type !== 'folder') {\n      throw new Error('Folder not found');\n    }\n    const stack = [info];\n    while (stack.length > 0) {\n      const current = stack.pop();\n      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  }","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/core/src/modules/organize/stores/folder.ts#L80-L116","documentation":"A lookup/type guard in removeFolder: it fetches folderId from the folders table and requires the record to exist with type 'folder'. It fires when a folder deletion is requested for an id that is missing or points at a link node — the faulting input is the folderId argument; recursive stack-based deletion is only defined for folders.","triggerScenarios":"Thrown by removeFolder when the folderId has no record in the folders DB or the record is not of type folder.","commonSituations":"Occurs when deleting a folder that was already removed or is actually a link node. Refresh the organize tree and retry the deletion.","solutions":["Verify the folder id; it may have been deleted.","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"}