{"record":{"id":"6842ac17c6a1f274","repo":"siyuan-note/siyuan","slug":"localized-block-not-found-message-conf-language-1","errorCode":null,"errorMessage":"localized block-not-found message (Conf.Language(15)) with block ID","messagePattern":"localized block-not-found message \\(Conf\\.Language\\(15\\)\\) with block ID","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/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/block.go#L825-L861","documentation":"GetHeadingDeleteTransaction builds the transaction that removes a heading and its children. Before inspecting the node it looks the block up in the parsed tree; if no node exists for the given ID it returns the localized block-not-found message (Conf.Language(15)) formatted with the block ID. The heading ID does not correspond to any existing block in the document tree.","triggerScenarios":"Calling GetHeadingDeleteTransaction (directly or via getHeadingDeleteTransaction) with a heading ID that no longer exists — the block was deleted in another session, the ID is mistyped, or the .sy file changed on disk without reindexing.","commonSituations":"Stale block IDs held by plugins/scripts after content changed, concurrent edits removing the heading, corrupted or manually edited .sy files, or a race between fetching the ID and building the transaction.","solutions":["Refresh the block ID from the current document (re-read the block via SQL/API) before calling the transaction builder","Confirm the document tree is indexed correctly (rebuild the index for the notebook if .sy files were edited externally)","Check that the ID is a valid 14-character node ID and belongs to the intended box/doc","If concurrent modification is possible, re-run the operation after syncing/reloading the document"],"exampleFix":"// before\nops, err := GetHeadingDeleteTransaction(staleHeadingID)\n// after\nif !treenode.IsNodeExist(staleHeadingID) { // or re-query the block first\n    return fmt.Errorf(\"heading %s no longer exists; refresh ID\", staleHeadingID)\n}\nops, err := GetHeadingDeleteTransaction(staleHeadingID)","handlingStrategy":"validation","validationCode":"// before building the delete transaction\nif (!blockExists(headingID)) {\n  throw new Error(`heading ${headingID} no longer exists`);\n}","typeGuard":"function hasNode(id) {\n  return typeof id === \"string\" && /^\\d{14}$/.test(id) && treeHasNode(id);\n}","tryCatchPattern":null,"preventionTips":["Re-resolve block IDs from the live document immediately before transactions","Reindex notebooks after any external .sy modification","Avoid caching block IDs across long-running operations or syncs"],"tags":["blocks","tree","not-found","localization"],"backgroundTag":"resource-not-found","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}