siyuan-note/siyuan · error
--id and --notebook are required
Error message
--id and --notebook are required
What it means
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.
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
Example fix
// before document move --id "$DOC_ID" // after document move --id "$DOC_ID" --notebook "$TARGET_NOTEBOOK" --hpath "/Inbox"
Defensive patterns
Strategy: validation
Validate before calling
if [ -z "$DOC_ID" ] || [ -z "$TARGET_NOTEBOOK" ]; then echo "--id and --notebook are required" >&2; exit 2; fi siyuan document move --id "$DOC_ID" --notebook "$TARGET_NOTEBOOK"
Prevention
- 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
When it happens
Trigger: Running `document move` with neither flag, only `--id`, or only `--notebook`; also when either flag is populated from an empty variable in a script.
Common situations: 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.
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
- --av and --ids are required
- --av, --key, --item and --value are required
- --block is required for non-detached rows
- --id is required
- --id is required
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/61634476899bcef2.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/cli/cmd/document.go:221
if err := model.RenameDoc(tree.Box, tree.Path, title); err != nil {
return err
}
model.AppendPushRenameEntry(tree.Box, tree.Path, title)
fmt.Println(id)
return nil
},
}
var documentMoveCmd = &cobra.Command{
Use: "move --id <id> --notebook <id>",
Short: "Move a document to another notebook",
RunE: func(cmd *cobra.Command, args []string) error {
id, _ := cmd.Flags().GetString("id")
toNotebook, _ := cmd.Flags().GetString("notebook")
toPath, _ := cmd.Flags().GetString("path")
hpath, _ := cmd.Flags().GetString("hpath")
if id == "" || toNotebook == "" {
return fmt.Errorf("--id and --notebook are required")
}
tree, err := model.LoadTreeByBlockID(id)
if err != nil {
return err
}
targetPath, err := resolveDocumentMovePath(toNotebook, toPath, hpath, tree.HPath)
if err != nil {
return err
}
if dryRun {
fmt.Printf("[dry-run] Would move document %s to notebook %s\n", id, toNotebook)
return nil
}
if err := model.MoveDocs([]string{tree.Path}, toNotebook, targetPath, nil); err != nil {
return errView on GitHub (pinned to 9f775e8a12)