siyuan-note/siyuan · error

Content block with id [%s] not found

Error message

Content block with id [%s] not found

What it means

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.

Source

Thrown at kernel/model/block.go:843

	if !sameTree {
		if err = indexWriteTreeUpsertQueue(defTree); err != nil {
			return
		}
	}
	FlushTxQueue()
	util.ReloadUI()
	return
}

func GetHeadingDeleteTransaction(id string) (transaction *Transaction, err error) {
	tree, err := LoadTreeByBlockID(id)
	if err != nil {
		return
	}

	node := treenode.GetNodeInTree(tree, id)
	if nil == node {
		err = fmt.Errorf(Conf.Language(15), id)
		return
	}

	if ast.NodeHeading != node.Type {
		return
	}

	var nodes []*ast.Node
	nodes = append(nodes, node)
	nodes = append(nodes, treenode.HeadingChildren(node)...)
	hiddenNodes := map[string]bool{}
	for _, hidden := range treenode.CollectFoldHiddenNodes(node.Parent) {
		hiddenNodes[hidden.ID] = true
	}

	transaction = &Transaction{}
	luteEngine := util.NewLute()
	for _, n := range nodes {

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Run Settings - Rebuild index to resync blocktree.db against the .sy files.
  2. 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.
  3. Reload the document in the editor to discard the stale block reference.
  4. If reproducible, inspect the .sy file to confirm whether the heading node is actually missing.
Defensive patterns

Strategy: validation

Validate before calling

row, err := sql.QueryRow("SELECT root_id FROM blocks WHERE id = ?", id)
if err != nil || row == nil {
    // block does not exist; skip heading-delete
    return nil
}

Try / catch

tx, err := model.GetHeadingDeleteTransaction(id)
if err != nil && strings.Contains(err.Error(), Conf.Language(15)) {
    // block gone - rebuild index or surface stale-state to the user
    return nil
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/9b5fcfe33b85f7ce. Report an issue: GitHub.