siyuan-note/siyuan · error

--ids is required (comma-separated shorthand IDs)

Error message

--ids is required (comma-separated shorthand IDs)

What it means

Thrown by the `inbox convert` subcommand when `--ids` is empty or yields no IDs after parsing. `parseShorthandIDs` splits the comma-separated value and trims empties; if nothing remains the command cannot convert anything. This check runs after the `--notebook` check.

Source

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

		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)
		if parentDir != "/" {
			bt := treenode.GetBlockTreeRootByHPath(notebook, parentDir)
			if bt == nil {
				return fmt.Errorf("parent path not found: %s", parentDir)
			}
			parentPath = strings.TrimSuffix(bt.Path, ".sy")

View on GitHub (pinned to 251596fc0d)

Solutions

  1. List inbox to get valid IDs: `siyuan inbox list`
  2. Pass a clean comma-separated list: `siyuan inbox convert --ids 1,2 --notebook <id>`

Example fix

// before
siyuan inbox convert --notebook 20240101 --ids ,,
// after
siyuan inbox convert --notebook 20240101 --ids 16890001,16890002
Defensive patterns

Strategy: validation

Validate before calling

ids := strings.Split(idsRaw, ",")
var clean []string
for _, s := range ids {
    if t := strings.TrimSpace(s); t != "" { clean = append(clean, t) }
}
if len(clean) == 0 {
    return errors.New("no valid shorthand IDs after parsing")
}

Prevention

When it happens

Trigger: Passing `--ids ""`, `--ids ",,"`, or omitting `--ids` entirely. `parseShorthandIDs` returns an empty slice and the length check trips the error.

Common situations: Pasting a malformed ID list with only commas; a variable that expanded to empty; forgetting the flag after `--notebook`.

Related errors


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