siyuan-note/siyuan · error

--label is required

Error message

--label is required

What it means

Thrown by the `tag remove` cobra subcommand when `--label` is empty. The label is the tag string to delete via `model.RemoveTag(label)`. The guard runs before the model call (and before `--dry-run`) so an empty label never reaches the removal engine. After removal the CLI also pushes a tag-reload event.

Source

Thrown at kernel/cli/cmd/tag.go:59

		switch outputFormat {
		case "json":
			data, _ := json.MarshalIndent(tags, "", "  ")
			fmt.Println(string(data))
		default:
			printTagTable(tags)
		}
		return nil
	},
}

var tagRemoveCmd = &cobra.Command{
	Use:   "remove --label <label>",
	Short: "Remove a tag",
	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 tag \"%s\"\n", label)
			return nil
		}

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

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

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Pass the exact label text: `siyuan tag remove --label "my-tag"`.
  2. List tags first to confirm the exact label: `siyuan tag list`.
  3. Quote labels containing spaces.

Example fix

// before
siyuan tag remove
// after
siyuan tag remove --label "reading"
Defensive patterns

Strategy: validation

Validate before calling

if label == "" {
    fmt.Fprintln(os.Stderr, "--label is required: pass the tag text")
    os.Exit(2)
}
// siyuan tag remove --label <label>

Prevention

When it happens

Trigger: Running `siyuan tag remove` with no `--label`, or `--label ""`. Also if the flag is spelled differently so cobra leaves it at default.

Common situations: Forgetting the label token; assuming the tag is identified by an ID rather than its label string (SiYuan tags are keyed by label text); scripting removal and passing an unset shell variable.

Related errors


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