{"record":{"id":"9b5fcfe33b85f7ce","repo":"siyuan-note/siyuan","slug":"content-block-with-id-s-not-found","errorCode":null,"errorMessage":"Content block with id [%s] not found","messagePattern":"Content block with id \\[(.+?)\\] not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/block.go","lineNumber":843,"sourceCode":"\tif !sameTree {\n\t\tif err = indexWriteTreeUpsertQueue(defTree); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\tFlushTxQueue()\n\tutil.ReloadUI()\n\treturn\n}\n\nfunc GetHeadingDeleteTransaction(id string) (transaction *Transaction, err error) {\n\ttree, err := LoadTreeByBlockID(id)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tnode := treenode.GetNodeInTree(tree, id)\n\tif nil == node {\n\t\terr = fmt.Errorf(Conf.Language(15), id)\n\t\treturn\n\t}\n\n\tif ast.NodeHeading != node.Type {\n\t\treturn\n\t}\n\n\tvar nodes []*ast.Node\n\tnodes = append(nodes, node)\n\tnodes = append(nodes, treenode.HeadingChildren(node)...)\n\thiddenNodes := map[string]bool{}\n\tfor _, hidden := range treenode.CollectFoldHiddenNodes(node.Parent) {\n\t\thiddenNodes[hidden.ID] = true\n\t}\n\n\ttransaction = &Transaction{}\n\tluteEngine := util.NewLute()\n\tfor _, n := range nodes {","sourceCodeStart":825,"sourceCodeEnd":861,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/block.go#L825-L861","documentation":"Returned by GetHeadingDeleteTransaction. LoadTreeByBlockID(id) succeeded (the ID exists in the blocktree and its tree was found), but treenode.GetNodeInTree(tree, id) returned nil - the node is not present in the loaded tree. Conf.Language(15) is the localized 'Content block with id [%s] not found' template. This signals a desync between blocktree.db and the actual .sy content.","triggerScenarios":"Calling heading-delete on an ID whose blocktree entry points at a tree that no longer contains it; operating after a sync conflict that rewrote the .sy file; the heading was already deleted but the editor still holds the ID.","commonSituations":"Blocktree out of sync after manual .sy edits; data repo corruption; the block was moved to another tree and the blocktree lagged; frontend cached an outdated block list.","solutions":["Run Settings - Rebuild index to resync blocktree.db against the .sy files.","Verify the ID with an SQL query (SELECT * FROM blocks WHERE id = '<id>'); if absent, the block is gone and the action should be a no-op.","Reload the document in the editor to discard the stale block reference.","If reproducible, inspect the .sy file to confirm whether the heading node is actually missing."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"row, err := sql.QueryRow(\"SELECT root_id FROM blocks WHERE id = ?\", id)\nif err != nil || row == nil {\n    // block does not exist; skip heading-delete\n    return nil\n}","typeGuard":null,"tryCatchPattern":"tx, err := model.GetHeadingDeleteTransaction(id)\nif err != nil && strings.Contains(err.Error(), Conf.Language(15)) {\n    // block gone - rebuild index or surface stale-state to the user\n    return nil\n}","preventionTips":["Reload the document in the editor before issuing block-targeted operations.","Rebuild the index periodically on installations that sync heavily.","Verify block IDs against the blocks table before calling heading APIs."],"tags":["block","heading","blocktree","desync"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}