siyuan-note/siyuan · error

previous block not found: %s

Error message

previous block not found: %s

What it means

Thrown inside `validateBlockMove` when `--previous` is provided but `treenode.GetBlockTree(previousID)` returns nil. The previous-sibling anchor must exist in the blocktree so the transaction can position the moved block after it. Same nil-return conditions as error [176] apply.

Source

Thrown at kernel/cli/cmd/block.go:446

		}
		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
	}
	return treenode.CheckContainerParent(parentID)
}

var blockBatchGetCmd = &cobra.Command{
	Use:   "batch-get --ids id1,id2,...",
	Short: "Batch get block info",
	RunE: func(cmd *cobra.Command, args []string) error {
		idsStr, _ := cmd.Flags().GetString("ids")
		if idsStr == "" {

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Verify the previous ID exists: `siyuan-kernel sql "SELECT id FROM blocks WHERE id='<previousID>'"`
  2. Drop `--previous` if you do not need sibling-anchored placement — the move will then use parent + nesting checks instead
  3. Ensure the sibling's notebook is mounted/unlocked

Example fix

// before
siyuan-kernel block move --id <mover> --parent <dest> --previous 00000000000000-x
// after
siyuan-kernel block move --id <mover> --parent <dest>  # omit --previous, or pass a verified sibling ID
Defensive patterns

Strategy: validation

Validate before calling

// Only set --previous when the sibling actually exists.
if previousID != "" {
    if treenode.GetBlockTree(previousID) == nil {
        return fmt.Errorf("previous sibling %s not found", previousID)
    }
}

Prevention

When it happens

Trigger: Passing `--previous <id>` where that ID is unknown, deleted, in an unmounted notebook, or in a locked encrypted notebook.

Common situations: Typo in the previous-sibling ID; sibling was deleted between planning and executing the move; sibling lives in a closed notebook.

Related errors


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