{"record":{"id":"7925c0b5b4255a86","repo":"toeverything/AFFiNE","slug":"cannot-rename-non-folder-node","errorCode":null,"errorMessage":"Cannot rename non-folder node","messagePattern":"Cannot rename non-folder node","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/frontend/core/src/modules/organize/stores/folder.ts","lineNumber":72,"sourceCode":"    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    }\n    this.dbService.db.folders.update(nodeId, {\n      data: name,\n    });\n  }\n\n  createFolder(parentId: string | null, name: string, index: string) {\n    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,","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/core/src/modules/organize/stores/folder.ts#L54-L90","documentation":"A type guard in renameNode: the node exists, but renaming by updating the node's data is only meaningful for folders (links mirror their target's name). It fires when nodeId resolves to a doc/tag/collection link rather than a folder — the caller must rename the underlying entity instead of the link node.","triggerScenarios":"Thrown by renameNode when the target node exists but its type is not folder, since only folder nodes store a renamable name in data.","commonSituations":"A rename was attempted on a doc, tag, or collection link in the organize tree instead of a folder. Rename the underlying doc or tag from its own UI instead.","solutions":["Only rename folder nodes; use the appropriate operation for docs/links.","Check the node type before renaming."],"exampleFix":null,"handlingStrategy":"validation","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"}