{"record":{"id":"ecf09791c3c95326","repo":"siyuan-note/siyuan","slug":"block-s-not-found","errorCode":null,"errorMessage":"block [%s] not found","messagePattern":"block \\[(.+?)\\] not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/block_update.go","lineNumber":125,"sourceCode":"\t\t\toldTree = treeCache[cacheKey]\n\t\t}\n\t\tif nil == oldTree {\n\t\t\tvar loadErr error\n\t\t\toldTree, loadErr = loadTree(input.ID)\n\t\t\tif loadErr != nil {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"load block tree [%s] failed: %w\", input.ID, loadErr)\n\t\t\t}\n\t\t\tif nil == oldTree || nil == oldTree.Root {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"load block tree [%s] failed: tree is empty\", input.ID)\n\t\t\t}\n\t\t\ttreeCache[blockUpdateTreeKey{boxID: oldTree.Box, rootID: oldTree.ID}] = oldTree\n\t\t\tif hasCacheKey {\n\t\t\t\ttreeCache[cacheKey] = oldTree\n\t\t\t}\n\t\t}\n\t\toldNode := treenode.GetNodeInTree(oldTree, input.ID)\n\t\tif nil == oldNode {\n\t\t\treturn nil, nil, fmt.Errorf(\"block [%s] not found\", input.ID)\n\t\t}\n\n\t\tif _, ok := rootIDSet[oldTree.ID]; !ok {\n\t\t\trootIDSet[oldTree.ID] = struct{}{}\n\t\t\trootIDs = append(rootIDs, oldTree.ID)\n\t\t}\n\n\t\tif ast.NodeDocument == oldNode.Type {\n\t\t\tif validateErr := treenode.ValidateBlockSubtree(dataTree.Root); validateErr != nil {\n\t\t\t\treturn nil, nil, validateErr\n\t\t\t}\n\t\t\tfor n := oldTree.Root.FirstChild; nil != n; n = n.Next {\n\t\t\t\tif !n.IsBlock() || ast.NodeKramdownBlockIAL == n.Type {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\toperations = append(operations, &Operation{Action: \"delete\", ID: n.ID, Data: map[string]any{\n\t\t\t\t\t\"createEmptyParagraph\": false, // 清空文档后前端不要创建空段落\n\t\t\t\t}})","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/block_update.go#L107-L143","documentation":"Returned by buildBlockUpdateOperations when loadTree succeeded with a non-empty Root, but treenode.GetNodeInTree(oldTree, input.ID) returned nil. The tree is fine; the specific block ID is not a node in it - same desync class as the block.go not-found errors, but inside the update pipeline.","triggerScenarios":"Block was moved/deleted between resolveTree's view and the load; blocktree entry points at a tree that no longer hosts the block; concurrent transaction rewrote the tree.","commonSituations":"Sync conflict; another client edited the document; blocktree lag after a recent move operation.","solutions":["Rebuild the index to reconcile blocktree.db with on-disk trees.","Verify via SQL that the block ID still maps to the expected root ID.","Reload the document and re-issue the update with a current block ID.","Retry once if a concurrent transaction is plausible; if it persists, surface 'block gone' to the user."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"row, _ := sql.QueryRow(\"SELECT root_id FROM blocks WHERE id = ?\", input.ID)\n// confirm input.ID is still mapped to a node in its tree before update","typeGuard":null,"tryCatchPattern":"ops, roots, err := buildBlockUpdateOperations(inputs, resolver, loader)\nif err != nil && strings.Contains(err.Error(), \"not found\") {\n    // reload document, refresh block IDs, retry\n}","preventionTips":["Reload the document before updates that target specific block IDs.","Rebuild the index after sync to remove stale blocktree entries.","Verify the block still belongs to its expected root via SQL."],"tags":["block-update","blocktree","desync"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}