siyuan-note/siyuan · error
get block failed:
Error message
get block failed:
What it means
buildUpdatedTaskListItemBlockDOM calls model.GetBlock(id, nil) to load a block by ID; on failure it wraps the underlying message in 'get block failed: ...'. The block ID could not be found or the underlying store query errored, so the task list item DOM cannot be rebuilt.
Solutions
- Verify the block ID exists (sql query or /api/query/block) before calling the operation
- Refresh the client's block reference from a recent DOM/SQL snapshot
- Rebuild the index (重建索引) if the block exists in the .sy file but not in the index
Example fix
// before await api.setBlockAttrs(deletedId, attrs) // after const block = await api.getBlockByID(id) if (block) await api.setBlockAttrs(id, attrs)
Defensive patterns
Strategy: validation
Validate before calling
const exists = await fetchPost('/api/query/block', {id});
if (!exists.data) throw new Error(`block ${id} gone`); Try / catch
try { await setBlockAttrs(id, attrs) } catch (e) { if (String(e).includes('get block failed')) await refreshBlockRefs(id) } Prevention
- Refresh block references after any delete/update transaction
- Handle index rebuilds by re-querying IDs
- Validate IDs come from recent getDoc responses
When it happens
Trigger: Calling the block-op endpoint (setBlockAttrs/updateBlock-style flows for task list items) with a block ID that does not exist in the SQL index or whose tree is missing.
Common situations: Stale client references after the block was deleted; unindexed docs (index queue lag); typo'd or truncated block ID.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- AI editor action not found
- block is not a list item
- Content block with id
- localized block-not-found message (Conf.Language(15)) with…
- parent block not found
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/a90a28052157a02e.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/api/block_op.go:37
import (
"errors"
"fmt"
"github.com/88250/gulu"
"github.com/88250/lute"
"github.com/88250/lute/ast"
"github.com/gin-gonic/gin"
"github.com/siyuan-note/siyuan/kernel/apicontract"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)
func buildUpdatedTaskListItemBlockDOM(id, marker string, luteEngine *lute.Lute) (data string, err error) {
block, err := model.GetBlock(id, nil)
if err != nil {
return "", errors.New("get block failed: " + err.Error())
}
if "NodeListItem" != block.Type {
return "", errors.New("block is not a list item")
}
tree, err := filesys.LoadTree(block.Box, block.Path, luteEngine)
if err != nil {
return "", errors.New("load tree failed: " + err.Error())
}
li := treenode.GetNodeInTree(tree, id)
if li == nil {
return "", errors.New("block not found")
}
if 3 != li.ListData.Typ {
return "", errors.New("block is not a task list item")View on GitHub (pinned to 9f775e8a12)