{"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":221,"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":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/document.go#L203-L239","documentation":"The `siyuan document move` command needs both `--id` (document/block to move) and `--notebook` (destination notebook ID). The guard returns this combined error when either flag is empty, before loading the tree via model.LoadTreeByBlockID.","triggerScenarios":"Running `document move` with neither flag, only `--id`, or only `--notebook`; also when either flag is populated from an empty variable in a script.","commonSituations":"Move automation where the destination notebook was resolved from a name that matched nothing and yielded an empty string; commands copied from rename examples that only mention --id; multi-step pipelines where an earlier step failed silently.","solutions":["Pass both flags: `siyuan document move --id <doc-id> --notebook <notebook-id>`","Resolve the notebook ID beforehand (from the workspace listing) and assert it is non-empty","Optionally also set --path and/or --hpath to choose the destination location inside the notebook"],"exampleFix":"// before\ndocument move --id \"$DOC_ID\"\n// after\ndocument move --id \"$DOC_ID\" --notebook \"$TARGET_NOTEBOOK\" --hpath \"/Inbox\"","handlingStrategy":"validation","validationCode":"if [ -z \"$DOC_ID\" ] || [ -z \"$TARGET_NOTEBOOK\" ]; then echo \"--id and --notebook are required\" >&2; exit 2; fi\nsiyuan document move --id \"$DOC_ID\" --notebook \"$TARGET_NOTEBOOK\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve and verify the destination notebook ID before any move operation","Do a dry run (if available) or test on a sample document first","Centralize notebook IDs in config instead of ad-hoc variables"],"tags":["cli","validation","missing-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"}