{"record":{"id":"61634476899bcef2","repo":"siyuan-note/siyuan","slug":"id-and-notebook-are-required","errorCode":null,"errorMessage":"--id and --notebook are required","messagePattern":"--id and --notebook are required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/document.go","lineNumber":217,"sourceCode":"\t\tif err := model.RenameDoc(tree.Box, tree.Path, title); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmodel.AppendPushRenameEntry(tree.Box, tree.Path, title)\n\t\tfmt.Println(id)\n\t\treturn nil\n\t},\n}\n\nvar documentMoveCmd = &cobra.Command{\n\tUse:   \"move --id <id> --notebook <id>\",\n\tShort: \"Move a document to another notebook\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tid, _ := cmd.Flags().GetString(\"id\")\n\t\ttoNotebook, _ := cmd.Flags().GetString(\"notebook\")\n\t\ttoPath, _ := cmd.Flags().GetString(\"path\")\n\t\thpath, _ := cmd.Flags().GetString(\"hpath\")\n\t\tif id == \"\" || toNotebook == \"\" {\n\t\t\treturn fmt.Errorf(\"--id and --notebook are required\")\n\t\t}\n\n\t\ttree, err := model.LoadTreeByBlockID(id)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\ttargetPath, err := resolveDocumentMovePath(toNotebook, toPath, hpath, tree.HPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif dryRun {\n\t\t\tfmt.Printf(\"[dry-run] Would move document %s to notebook %s\\n\", id, toNotebook)\n\t\t\treturn nil\n\t\t}\n\n\t\tif err := model.MoveDocs([]string{tree.Path}, toNotebook, targetPath, nil); err != nil {\n\t\t\treturn err","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/document.go#L199-L235","documentation":"The `document move` cobra subcommand requires both --id (the document to move) and --notebook (the destination notebook). The handler returns this error when either is empty, before loading the source tree and before resolving the destination path via resolveDocumentMovePath. The --path and --hpath flags are optional and only specify where inside the destination notebook the document lands.","triggerScenarios":"Running `siyuan document move --id <id>` without --notebook, or `--notebook <id>` without --id, or omitting both; passing empty values; scripting with unset variables.","commonSituations":"Forgetting the destination notebook; assuming the document moves within the same notebook by default; referencing shell variables that are empty; confusing the source notebook (derived from the doc) with the destination --notebook flag.","solutions":["Supply both flags: `siyuan document move --id <id> --notebook <destNotebookId>`.","Look up IDs via `document list` / `notebook list`.","Guard both variables in scripts and abort if either is empty.","Use `--dry-run` to preview the resolved destination before moving.","Verify flags with `siyuan document move --help`."],"exampleFix":"// before\nsiyuan document move --id 20240101000000-abc1234\n// after\nsiyuan document move --id 20240101000000-abc1234 --notebook 20240202000000-dest","handlingStrategy":"validation","validationCode":"[ -n \"$DOC_ID\" ] && [ -n \"$DEST_NB\" ] || { echo '--id and --notebook are required' >&2; exit 2; }\nsiyuan document move --dry-run --id \"$DOC_ID\" --notebook \"$DEST_NB\" && siyuan document move --id \"$DOC_ID\" --notebook \"$DEST_NB\"","typeGuard":null,"tryCatchPattern":"if ! siyuan document move --id \"$DOC_ID\" --notebook \"$DEST_NB\" 2>err.txt; then\n  grep -q 'required' err.txt && echo \"pass both --id and --notebook\" >&2\n  exit 1\nfi","preventionTips":["Resolve destination notebook id via `siyuan notebook list`.","Always --dry-run move to preview the resolved path.","Guard both variables and use `set -u`."],"tags":["cli","cobra","flag-validation","document","notebook","go"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}