{"record":{"id":"827fb1703cb599e4","repo":"siyuan-note/siyuan","slug":"id-and-parent-are-required","errorCode":null,"errorMessage":"--id and --parent are required","messagePattern":"--id and --parent are required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/block.go","lineNumber":416,"sourceCode":"\t\tmodel.FlushTxQueue()\n\n\t\tif bt != nil {\n\t\t\tmodel.AppendPushReloadProtyleEntry(bt.RootID)\n\t\t}\n\t\tfmt.Println(id)\n\t\treturn nil\n\t},\n}\n\nvar blockMoveCmd = &cobra.Command{\n\tUse:   \"move --id <id> --parent <id>\",\n\tShort: \"Move block\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tid, _ := cmd.Flags().GetString(\"id\")\n\t\tparentID, _ := cmd.Flags().GetString(\"parent\")\n\t\tpreviousID, _ := cmd.Flags().GetString(\"previous\")\n\t\tif id == \"\" || parentID == \"\" {\n\t\t\treturn fmt.Errorf(\"--id and --parent are required\")\n\t\t}\n\n\t\tif err := validateBlockMove(id, parentID, previousID); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif dryRun {\n\t\t\tfmt.Printf(\"[dry-run] Would move block %s to parent %s\\n\", id, parentID)\n\t\t\tif previousID != \"\" {\n\t\t\t\tfmt.Printf(\"         after previous sibling %s\\n\", previousID)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\n\t\ttransaction := &model.Transaction{\n\t\t\tDoOperations: []*model.Operation{{\n\t\t\t\tAction:     \"move\",\n\t\t\t\tID:         id,","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/block.go#L398-L434","documentation":"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.","triggerScenarios":"Running `siyuan block move` with only --id, only --parent, or neither; empty flag values also count.","commonSituations":"Scripts that supply the target conditionally and drop --parent when moving to root; unset shell variables; mistaking --previous (optional) for required.","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."],"exampleFix":"// before\nsiyuan block move --id 20240101120000-h1x2y3z\n// after\nsiyuan block move --id 20240101120000-h1x2y3z --parent 20240101120000-p9a8b7c6","handlingStrategy":"validation","validationCode":"[ -n \"$BLOCK_ID\" ] && [ -n \"$PARENT_ID\" ] || { echo \"--id and --parent are required\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"siyuan block move --id \"$BLOCK_ID\" --parent \"$PARENT_ID\" ${PREVIOUS_ID:+--previous \"$PREVIOUS_ID\"} || exit $?","preventionTips":["Always pass both --id and --parent for move","Remember --previous is optional positional hint","Validate variables before composing the command"],"tags":["cli","validation","flag"],"backgroundTag":"missing-required-flag","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}