siyuan-note/siyuan · error
--id and --parent are required
Error message
--id and --parent are required
What it means
Argument validation in the cobra blockMove RunE: fires when either --id or --parent is empty. Moving a block requires both the source block ID and the destination parent block ID; omitting either flag is the faulting usage. Further sanity checks are done by validateBlockMove.
Solutions
- Provide both --id <blockID> and --parent <blockID>.
- Check both variables are non-empty before invoking.
- Optionally add --previous <blockID> to control position among the new siblings.
Example fix
// before siyuan block move --id 20240101120000-h1x2y3z // after siyuan block move --id 20240101120000-h1x2y3z --parent 20240101120000-p9a8b7c6
Defensive patterns
Strategy: validation
Validate before calling
[ -n "$BLOCK_ID" ] && [ -n "$PARENT_ID" ] || { echo "--id and --parent are required" >&2; exit 1; } Try / catch
siyuan block move --id "$BLOCK_ID" --parent "$PARENT_ID" ${PREVIOUS_ID:+--previous "$PREVIOUS_ID"} || exit $? Prevention
- Always pass both --id and --parent for move
- Remember --previous is optional positional hint
- Validate variables before composing the command
When it happens
Trigger: Running `siyuan block move` with only --id, only --parent, or neither; empty flag values also count.
Common situations: Scripts that supply the target conditionally and drop --parent when moving to root; unset shell variables; mistaking --previous (optional) for required.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- --parent is required
- --av and --ids are required
- --av and --key are required
- --av is required
- --av, --key, --item and --value are required
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/827fb1703cb599e4.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/cli/cmd/block.go:416
model.FlushTxQueue()
if bt != nil {
model.AppendPushReloadProtyleEntry(bt.RootID)
}
fmt.Println(id)
return nil
},
}
var blockMoveCmd = &cobra.Command{
Use: "move --id <id> --parent <id>",
Short: "Move block",
RunE: func(cmd *cobra.Command, args []string) error {
id, _ := cmd.Flags().GetString("id")
parentID, _ := cmd.Flags().GetString("parent")
previousID, _ := cmd.Flags().GetString("previous")
if id == "" || parentID == "" {
return fmt.Errorf("--id and --parent are required")
}
if err := validateBlockMove(id, parentID, previousID); err != nil {
return err
}
if dryRun {
fmt.Printf("[dry-run] Would move block %s to parent %s\n", id, parentID)
if previousID != "" {
fmt.Printf(" after previous sibling %s\n", previousID)
}
return nil
}
transaction := &model.Transaction{
DoOperations: []*model.Operation{{
Action: "move",
ID: id,View on GitHub (pinned to 9f775e8a12)