siyuan-note/siyuan · error

--label is required

Error message

--label is required

What it means

Thrown by the `bookmark remove` cobra subcommand when the `--label` flag is empty. Bookmarks in SiYuan are keyed by a label string, so removing one requires the exact label. The guard runs before any model mutation (`model.RemoveBookmark`).

Source

Thrown at kernel/cli/cmd/bookmark.go:78

		default:
			w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
			fmt.Fprintln(w, "LABEL")
			for _, l := range labels {
				fmt.Fprintln(w, l)
			}
			w.Flush()
		}
		return nil
	},
}

var bookmarkRemoveCmd = &cobra.Command{
	Use:   "remove --label <label>",
	Short: "Remove a bookmark",
	RunE: func(cmd *cobra.Command, args []string) error {
		label, _ := cmd.Flags().GetString("label")
		if label == "" {
			return fmt.Errorf("--label is required")
		}

		if dryRun {
			fmt.Printf("[dry-run] Would remove bookmark \"%s\"\n", label)
			return nil
		}

		if err := model.RemoveBookmark(label); err != nil {
			return err
		}
		model.AppendPushReloadFiletreeEntry()
		return nil
	},
}

var bookmarkRenameCmd = &cobra.Command{
	Use:   "rename --old <old> --new <new>",
	Short: "Rename a bookmark",

View on GitHub (pinned to 251596fc0d)

Solutions

  1. List existing bookmarks first (e.g. via the bookmark search/list command or `siyuan bookmark list`) to copy the exact label
  2. Pass the label verbatim: `siyuan bookmark remove --label "我的书签"`
  3. Confirm the flag is `--label`, not `--name`/`--bookmark`

Example fix

// before
siyuan bookmark remove

// after
siyuan bookmark remove --label "Inbox"
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(label) == "" {
    log.Fatal("--label is required to remove a bookmark")
}

Prevention

When it happens

Trigger: Running `siyuan bookmark remove` without `--label`, or with an empty value, or before dry-run handling.

Common situations: Forgetting the label, mistyping as `--name`, or copying a label with trailing whitespace that the shell strips.

Related errors


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