siyuan-note/siyuan · error

--notebook is required

Error message

--notebook is required

What it means

Thrown by the `inbox convert` subcommand when `--notebook` is empty. The notebook ID selects the destination for converting cloud shorthands into local documents. This is the first validation, ahead of `--ids` and the parent-path lookup.

Source

Thrown at kernel/cli/cmd/inbox.go:129

			if url != "" {
				fmt.Println("URL:    ", url)
			}
			fmt.Println("\nMARKDOWN:")
			fmt.Println(md)
		}
		return nil
	},
}

// inboxConvertCmd 把一条或多条剪藏转为本地文档:取云端 md → 本地建文档 → 成功后清理云端原件。
// 失败的条目不会被删除,也不会中断后续条目的处理;输出逐条结果。
var inboxConvertCmd = &cobra.Command{
	Use:   "convert --ids <id1,id2,...> --notebook <id> [--path </h/path>] [--remove-after]",
	Short: "Convert cloud inbox shorthands into local documents",
	RunE: func(cmd *cobra.Command, args []string) error {
		notebook, _ := cmd.Flags().GetString("notebook")
		if notebook == "" {
			return fmt.Errorf("--notebook is required")
		}

		idsRaw, _ := cmd.Flags().GetString("ids")
		ids := parseShorthandIDs(idsRaw)
		if len(ids) == 0 {
			return fmt.Errorf("--ids is required (comma-separated shorthand IDs)")
		}

		hPath, _ := cmd.Flags().GetString("path")
		if hPath == "" {
			hPath = "/"
		}
		removeAfter, _ := cmd.Flags().GetBool("remove-after")

		// 解析目标父路径(hPath→fsPath):hPath 指向新文档将要落入的父容器,
		// 其父目录必须已存在;不传或传 "/" 时落到笔记本根目录。
		parentPath := "/"
		parentDir := parentDir(hPath)

View on GitHub (pinned to 251596fc0d)

Solutions

  1. List notebooks: `siyuan notebook list`
  2. Pass both flags: `siyuan inbox convert --ids 1,2 --notebook <id>`

Example fix

// before
siyuan inbox convert --ids 1,2,3
// after
siyuan inbox convert --ids 1,2,3 --notebook 20240101120000-abc
Defensive patterns

Strategy: validation

Validate before calling

if notebook == "" {
    out, _ := cmd.Output("siyuan", "notebook", "list")
    log.Fatalf("destination notebook ID required:\n%s", out)
}

Prevention

When it happens

Trigger: Running `siyuan inbox convert --ids 1,2,3` without `--notebook`. The RunE checks the notebook flag before parsing the `--ids` list.

Common situations: Omitting the destination notebook; using a notebook name instead of its ID; scripting convert without a target.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/83b9731e5eb0a936. Report an issue: GitHub.