{"record":{"id":"888a9bbbb151d0fc","repo":"siyuan-note/siyuan","slug":"not-query-embed-block","errorCode":null,"errorMessage":"not query embed block","messagePattern":"not query embed block","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/search.go","lineNumber":213,"sourceCode":"\tpageCount = (matchedBlockCount + pageSize - 1) / pageSize\n\treturn\n}\n\ntype EmbedBlock struct {\n\tBlock               *Block       `json:\"block\"`\n\tBlockPaths          []*BlockPath `json:\"blockPaths\"`\n\tAllowChildOperation bool         `json:\"allowChildOperation\"`\n}\n\nfunc UpdateEmbedBlock(id, content string) (err error) {\n\tbt := treenode.GetBlockTree(id)\n\tif nil == bt {\n\t\terr = ErrBlockNotFound\n\t\treturn\n\t}\n\n\tif treenode.TypeAbbr(ast.NodeBlockQueryEmbed.String()) != bt.Type {\n\t\terr = errors.New(\"not query embed block\")\n\t\treturn\n\t}\n\n\tembedBlock := &EmbedBlock{\n\t\tBlock: &Block{\n\t\t\tMarkdown: content,\n\t\t},\n\t}\n\n\tupdateEmbedBlockContent(id, []*EmbedBlock{embedBlock}, bt.BoxID)\n\treturn\n}\n\nfunc GetEmbedBlock(embedBlockID string, includeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock) {\n\treturn getEmbedBlock(embedBlockID, includeIDs, headingMode, breadcrumb, true, \"\")\n}\n\nfunc GetEmbedBlockInBox(embedBlockID string, includeIDs []string, headingMode int, breadcrumb bool, boxID string) (ret []*EmbedBlock) {","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/search.go#L195-L231","documentation":"UpdateEmbedBlock updates the content of a query embed block (^(...) block). The library fetches the block tree for the given block ID and verifies that the block's type is actually a block-query-embed node; if the ID points to any other node type (paragraph, heading, etc.), it refuses with \"not query embed block\". This guards against writing embed-block content onto a normal block.","triggerScenarios":"Calling UpdateEmbedBlock with an id whose block tree record has a type other than treenode.TypeAbbr(ast.NodeBlockQueryEmbed.String()) — e.g. passing a regular paragraph or heading block ID — produces this error immediately after the ErrBlockNotFound check passes.","commonSituations":"Frontend passes the wrong block ID when refreshing embed blocks (e.g. the containing block instead of the embed block itself); stale block IDs after a document was edited so the node changed type; plugins calling the embed-block update API with arbitrary block IDs.","solutions":["Verify the block ID actually refers to a query embed block (its .sy node type is NodeBlockQueryEmbed) before calling UpdateEmbedBlock","Re-fetch the block via the block tree / SQL to confirm its current type; the ID may point to a block whose type changed after edits","If you intend to update a normal block, use the block update API instead of the embed-block one"],"exampleFix":"// before\nmodel.UpdateEmbedBlock(paraBlockID, content) // id is a paragraph block\n// after\nbt := treenode.GetBlockTree(blockID)\nif bt != nil && treenode.TypeAbbr(ast.NodeBlockQueryEmbed.String()) == bt.Type {\n    model.UpdateEmbedBlock(blockID, content)\n}","handlingStrategy":"validation","validationCode":"const bt = GetBlockTree(blockID)\nif (!bt || bt.type !== 'query_embed') throw new Error('block is not a query embed block')\nawait api.updateEmbedBlock(blockID, content)","typeGuard":"function isQueryEmbedBlock(bt) { return bt != null && bt.type === 'query_embed' }","tryCatchPattern":"try { await api.updateEmbedBlock(id, content) } catch (e) { if (String(e).includes('not query embed block')) skipNonEmbed(id); else throw e }","preventionTips":["Resolve embed block IDs via SQL with type filter, not arbitrary block IDs","Re-fetch block type before each update; IDs can change type after edits","Log bt.type on failure to diagnose ID mismatches quickly"],"tags":["embed-block","block-type-mismatch","siyuan"],"backgroundTag":"incompatible-source-type","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"}