{"record":{"id":"c1f378942d57a547","repo":"toeverything/AFFiNE","slug":"root-node-can-only-have-folders","errorCode":null,"errorMessage":"Root node can only have folders","messagePattern":"Root node can only have folders","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/frontend/core/src/modules/organize/stores/folder.ts","lineNumber":145,"sourceCode":"    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);\n      if (parent === null || parent.type !== 'folder') {\n        throw new Error('Parent folder not found');\n      }\n    } else {\n      if (node.type !== 'folder') {\n        throw new Error('Root node can only have folders');\n      }\n    }\n    this.dbService.db.folders.update(nodeId, {\n      parentId,\n      index,\n    });\n  }\n}\n","sourceCodeStart":127,"sourceCodeEnd":154,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/core/src/modules/organize/stores/folder.ts#L127-L154","documentation":"A root-level invariant guard in moveNode: when parentId is null the node is being moved to the root of the organize tree, and only folders may exist at root level. It fires when a doc/tag/collection link is moved to the root (no parent) — links must always live inside a folder.","triggerScenarios":"Thrown by moveNode when moving a non-folder node (doc/tag/collection link) to the root (parentId null), since the root level of the organize tree only accepts folders.","commonSituations":"Occurs when dragging a doc or tag link to the top level of the sidebar tree. Place links inside a folder instead of at root.","solutions":["Only create folders at the root of the organize tree.","Move non-folder nodes into a folder instead."],"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-14T05:17:10.506Z"}