{"record":{"id":"83b9731e5eb0a936","repo":"siyuan-note/siyuan","slug":"notebook-is-required-83b973","errorCode":null,"errorMessage":"--notebook is required","messagePattern":"--notebook is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/inbox.go","lineNumber":129,"sourceCode":"\t\t\tif url != \"\" {\n\t\t\t\tfmt.Println(\"URL:    \", url)\n\t\t\t}\n\t\t\tfmt.Println(\"\\nMARKDOWN:\")\n\t\t\tfmt.Println(md)\n\t\t}\n\t\treturn nil\n\t},\n}\n\n// inboxConvertCmd 把一条或多条剪藏转为本地文档：取云端 md → 本地建文档 → 成功后清理云端原件。\n// 失败的条目不会被删除，也不会中断后续条目的处理；输出逐条结果。\nvar inboxConvertCmd = &cobra.Command{\n\tUse:   \"convert --ids <id1,id2,...> --notebook <id> [--path </h/path>] [--remove-after]\",\n\tShort: \"Convert cloud inbox shorthands into local documents\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tnotebook, _ := cmd.Flags().GetString(\"notebook\")\n\t\tif notebook == \"\" {\n\t\t\treturn fmt.Errorf(\"--notebook is required\")\n\t\t}\n\n\t\tidsRaw, _ := cmd.Flags().GetString(\"ids\")\n\t\tids := parseShorthandIDs(idsRaw)\n\t\tif len(ids) == 0 {\n\t\t\treturn fmt.Errorf(\"--ids is required (comma-separated shorthand IDs)\")\n\t\t}\n\n\t\thPath, _ := cmd.Flags().GetString(\"path\")\n\t\tif hPath == \"\" {\n\t\t\thPath = \"/\"\n\t\t}\n\t\tremoveAfter, _ := cmd.Flags().GetBool(\"remove-after\")\n\n\t\t// 解析目标父路径（hPath→fsPath）：hPath 指向新文档将要落入的父容器，\n\t\t// 其父目录必须已存在；不传或传 \"/\" 时落到笔记本根目录。\n\t\tparentPath := \"/\"\n\t\tparentDir := parentDir(hPath)","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/inbox.go#L111-L147","documentation":"The `inbox convert` CLI command requires the `--notebook` flag to know which local notebook the cloud inbox shorthands should be converted into. The command returns this error before doing any work when the flag is empty or unset. It is a deliberate pre-flight argument check in the cobra RunE handler.","triggerScenarios":"Running `siyuan inbox convert --ids <id1,id2>` without `--notebook <id>`, or passing `--notebook \"\"`.","commonSituations":"Copy-pasting a command from docs and dropping the notebook ID; scripting the convert step and forgetting to parameterize the target notebook; assuming a default notebook would be used (none exists).","solutions":["Add `--notebook <id>` with the target notebook's ID (the ID shown in the SiYuan UI or printed by notebook create).","List available notebook IDs first (e.g. via the kernel API /api/notebook/lsNotebooks) to get a valid ID.","If scripting, ensure the variable holding the notebook ID is not empty before invoking the command."],"exampleFix":"// before\nsiyuan inbox convert --ids abc123,def456\n// after\nsiyuan inbox convert --ids abc123,def456 --notebook 20240101120000-abcd123","handlingStrategy":"validation","validationCode":"if [ -z \"$NOTEBOOK\" ]; then echo \"--notebook is required\"; exit 1; fi\nsiyuan inbox convert --ids \"$IDS\" --notebook \"$NOTEBOOK\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --notebook explicitly; there is no default notebook","Resolve the notebook ID from the lsNotebooks API at script start","Quote flag values in shell scripts"],"tags":["cli","missing-flag","validation"],"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"}