siyuan-note/siyuan · error
not query embed block
Error message
not query embed block
What it means
The UpdateEmbedBlock function updates the content of an embed block (NodeBlockQueryEmbed type). It first looks up the block in the block tree, then verifies the block type matches 'NodeBlockQueryEmbed' via treenode.TypeAbbr. If the block ID exists but is a different block type (paragraph, heading, list, etc.), this error is returned. The block type check prevents corrupting non-embed blocks with embed-block-specific update logic.
Source
Thrown at kernel/model/search.go:206
pageCount = (matchedBlockCount + pageSize - 1) / pageSize
return
}
type EmbedBlock struct {
Block *Block `json:"block"`
BlockPaths []*BlockPath `json:"blockPaths"`
AllowChildOperation bool `json:"allowChildOperation"`
}
func UpdateEmbedBlock(id, content string) (err error) {
bt := treenode.GetBlockTree(id)
if nil == bt {
err = ErrBlockNotFound
return
}
if treenode.TypeAbbr(ast.NodeBlockQueryEmbed.String()) != bt.Type {
err = errors.New("not query embed block")
return
}
embedBlock := &EmbedBlock{
Block: &Block{
Markdown: content,
},
}
updateEmbedBlockContent(id, []*EmbedBlock{embedBlock}, bt.BoxID)
return
}
func GetEmbedBlock(embedBlockID string, includeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock) {
return getEmbedBlock(embedBlockID, includeIDs, headingMode, breadcrumb, true, "")
}
func GetEmbedBlockInBox(embedBlockID string, includeIDs []string, headingMode int, breadcrumb bool, boxID string) (ret []*EmbedBlock) {View on GitHub (pinned to 251596fc0d)
Solutions
- Verify the block type is NodeBlockQueryEmbed before calling UpdateEmbedBlock by checking treenode.GetBlockTree(id).Type
- Refresh the block ID from the current block tree if the caller's reference may be stale
- If the block was intentionally converted to a different type, the update call should be skipped or redirected to the appropriate block-type-specific API
Example fix
// before
err = model.UpdateEmbedBlock(blockID, newContent)
// after
bt := treenode.GetBlockTree(blockID)
if bt == nil {
return model.ErrBlockNotFound
}
if treenode.TypeAbbr(ast.NodeBlockQueryEmbed.String()) != bt.Type {
return fmt.Errorf("block %s is not an embed block (type: %s)", blockID, bt.Type)
}
err = model.UpdateEmbedBlock(blockID, newContent) Defensive patterns
Strategy: type-guard
Validate before calling
// Verify block is an embed block before updating
bt := treenode.GetBlockTree(id)
if bt == nil {
return model.ErrBlockNotFound
}
if treenode.TypeAbbr(ast.NodeBlockQueryEmbed.String()) != bt.Type {
return fmt.Errorf("block %s is type %s, not an embed block", id, bt.Type)
} Type guard
// Check if a block is an embed block (NodeBlockQueryEmbed)
func isEmbedBlock(id string) bool {
bt := treenode.GetBlockTree(id)
if bt == nil {
return false
}
return treenode.TypeAbbr(ast.NodeBlockQueryEmbed.String()) == bt.Type
} Prevention
- Always type-check block IDs from user input or stale references before calling type-specific block APIs
- Refresh block tree references when the UI context changes (block conversion, deletion, etc.)
- Provide a unified block-type-aware dispatch in the frontend rather than calling embed-specific APIs blindly
When it happens
Trigger: Calling UpdateEmbedBlock(id, content) where id resolves to a valid block in the block tree, but that block's type is not NodeBlockQueryEmbed. This can happen when a stale or incorrect block ID is passed, or when the embed block was converted to a different block type but the caller still has the old ID.
Common situations: Frontend calls UpdateEmbedBlock with a block ID from a stale context (e.g., after the block was converted from embed to another type via the UI). Also occurs when plugins or external API consumers pass arbitrary block IDs without verifying they are embed blocks first. Race conditions where the block type changes between the UI rendering and the update call.
Related errors
- parent path not found: %s
- Failed to update agent session permission
- Agent capability name and description are required
- invalid frontend capability ID: %s
- frontend capability description is required: %s
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/888a9bbbb151d0fc.
Report an issue: GitHub.