siyuan-note/siyuan · error
block not found: %s
Error message
block not found: %s
What it means
Thrown inside `validateBlockMove(id, parentID, previousID)` when `treenode.GetBlockTree(id)` returns nil — the block to be moved is not present in the `blocktrees` SQLite table. `GetBlockTree` returns nil for unknown IDs, unmounted notebooks, encrypted-but-locked notebooks, and DB errors. This is a data-existence error, not an argument error.
Source
Thrown at kernel/cli/cmd/block.go:437
ParentID: parentID,
PreviousID: previousID,
}},
}
if err := model.PerformTxSync(transaction); err != nil {
return err
}
if bt := treenode.GetBlockTree(id); bt != nil {
model.AppendPushReloadProtyleEntry(bt.RootID)
}
fmt.Println("ok")
return nil
},
}
func validateBlockMove(id, parentID, previousID string) error {
bt := treenode.GetBlockTree(id)
if nil == bt {
return fmt.Errorf("block not found: %s", id)
}
if "d" == bt.Type {
return fmt.Errorf("document block [%s] cannot be moved with block move; use document move instead", id)
}
if "" != previousID {
previousBt := treenode.GetBlockTree(previousID)
if nil == previousBt {
return fmt.Errorf("previous block not found: %s", previousID)
}
if "d" == previousBt.Type {
return fmt.Errorf("document block [%s] cannot be used as a previous sibling; use it as --parent instead", previousID)
}
return nil
}
if err := treenode.CheckListItemNesting(parentID, id); err != nil {
return err
}View on GitHub (pinned to 251596fc0d)
Solutions
- Confirm existence: `siyuan-kernel sql "SELECT id,type FROM blocks WHERE id='<id>'"`
- Ensure the owning notebook is mounted/opened in this workspace
- Unlock encrypted notebooks so the blocktree lookup (which falls back to per-box scan) can resolve them
- Wait for kernel indexing to finish, then retry
Example fix
// before siyuan-kernel block move --id 00000000000000-nonexist --parent <dest> // after siyuan-kernel block move --id 20260605100657-v080a4j --parent <dest> # verified via sql
Defensive patterns
Strategy: validation
Validate before calling
// Confirm the mover block exists before attempting the move.
bt := treenode.GetBlockTree(moverID)
if bt == nil {
return fmt.Errorf("mover block %s not found; cannot move", moverID)
} Type guard
func blockExists(id string) bool {
return strings.TrimSpace(id) != "" && treenode.GetBlockTree(id) != nil
} Prevention
- Resolve the blocktree entry once and reuse it for type checks too (covers errors 176, 177)
- Mount/unlock relevant notebooks before batch moves
- Wait for indexing to finish before relying on blocktree lookups
When it happens
Trigger: Passing an `--id` that does not exist in the current workspace; the block's notebook is closed; the blocktree DB is not yet populated (kernel still indexing); the ID was deleted.
Common situations: Stale block ID copied from another workspace; running the CLI before indexing completes; encrypted notebook not unlocked; typo or truncated ID.
Related errors
- previous block not found: %s
- document not found or empty
- document block [%s] cannot be moved with block move; use doc
- document block [%s] cannot be used as a previous sibling; us
- --id is required
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/afb59e4d0d1d56ba.
Report an issue: GitHub.