{"record":{"id":"d708f1138ad334e0","repo":"siyuan-note/siyuan","slug":"load-tree-failed","errorCode":null,"errorMessage":"load tree failed: ","messagePattern":"load tree failed: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/api/block_op.go","lineNumber":46,"sourceCode":"\t\"github.com/siyuan-note/siyuan/kernel/filesys\"\n\t\"github.com/siyuan-note/siyuan/kernel/model\"\n\t\"github.com/siyuan-note/siyuan/kernel/treenode\"\n\t\"github.com/siyuan-note/siyuan/kernel/util\"\n)\n\nfunc buildUpdatedTaskListItemBlockDOM(id, marker string, luteEngine *lute.Lute) (data string, err error) {\n\tblock, err := model.GetBlock(id, nil)\n\tif err != nil {\n\t\treturn \"\", errors.New(\"get block failed: \" + err.Error())\n\t}\n\n\tif \"NodeListItem\" != block.Type {\n\t\treturn \"\", errors.New(\"block is not a list item\")\n\t}\n\n\ttree, err := filesys.LoadTree(block.Box, block.Path, luteEngine)\n\tif err != nil {\n\t\treturn \"\", errors.New(\"load tree failed: \" + err.Error())\n\t}\n\n\tli := treenode.GetNodeInTree(tree, id)\n\tif li == nil {\n\t\treturn \"\", errors.New(\"block not found\")\n\t}\n\n\tif 3 != li.ListData.Typ {\n\t\treturn \"\", errors.New(\"block is not a task list item\")\n\t}\n\n\tif 1 != len(marker) {\n\t\treturn \"\", errors.New(\"task list item marker length should be 1\")\n\t}\n\n\tliMarker := marker[0]\n\tif '[' == liMarker || ']' == liMarker {\n\t\treturn \"\", errors.New(\"task list item marker can not be [ or ]\")","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/api/block_op.go#L28-L64","documentation":"After the block type check, the function loads the containing .sy document via filesys.LoadTree; failure (missing/corrupt file, IO error) is wrapped as 'load tree failed: ...' with the cause appended. The block row exists in the index but its source document cannot be parsed.","triggerScenarios":"model.GetBlock succeeded but the .sy file on disk is missing, unreadable, or unparseable (corrupted JSON, partial sync write, file deleted between index and load).","commonSituations":"Docs deleted while the SQL index still references them; interrupted sync leaving truncated .sy files; permissions problems in the workspace data dir.","solutions":["Restore or re-sync the missing/corrupt .sy file (check 历史/history or cloud sync)","Rebuild the index so stale block rows pointing at deleted docs are purged","Check file system permissions on data/<box>/**"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check the source doc file exists before block ops\nconst doc = await fetchPost('/api/filetree/getDoc', {id});\nif (!doc.data) throw new Error('doc missing');","typeGuard":null,"tryCatchPattern":"try { await updateTaskItem(id) } catch (e) { if (String(e).includes('load tree failed')) await rebuildIndexAndRetry(id) }","preventionTips":["Keep sync interruptions rare; verify data integrity after crash/sync","Restore .sy files from history instead of continuing on corrupt docs","Run 重建索引 when block rows and files diverge"],"tags":["tree","file-io","corruption"],"backgroundTag":"file-read-failed","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}