siyuan-note/siyuan · error

--name is required

Error message

--name is required

What it means

Argument validation in the cobra repoUntagCmd RunE: fires when the --name flag is empty. Removing a snapshot tag requires the tag name to pass to model.RemoveTagSnapshot; running `repo untag` without --name is the faulting usage.

Solutions

  1. Re-run with: `siyuan repo untag --name <tagName>`
  2. Verify the tag name variable is set in your script
  3. Note that unlike `tag`, this command needs only `--name` (no `--id`)

Example fix

// before
siyuan repo untag v1
// after
siyuan repo untag --name v1
Defensive patterns

Strategy: validation

Validate before calling

[ -n "$TAG_NAME" ] || { echo "repo untag: missing --name" >&2; exit 2; }
siyuan repo untag --name "$TAG_NAME"

Type guard

function requireFlag(v) { if (typeof v !== 'string' || v.trim() === '') throw new Error('--name is required'); return v; }

Try / catch

siyuan repo untag --name "$TAG_NAME" || { echo 'pass the tag via --name, not as a positional argument'; }

Prevention

When it happens

Trigger: Running `siyuan repo untag` without `--name`, or with `--name ""`; e.g. `siyuan repo untag` expecting an interactive prompt.

Common situations: Assuming the command takes a positional argument instead of a flag; scripts where the tag-name variable is unset; deleting a flag when refactoring a command line.

Understand the failure class

Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/a27745ae6c3f4c37. Report an issue: GitHub.

Appendix: source

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

			fmt.Printf("[dry-run] Would tag snapshot %s with \"%s\"\n", id, name)
			return nil
		}

		if err := model.TagSnapshot(id, name); err != nil {
			return err
		}
		fmt.Println("ok")
		return nil
	},
}

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

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

		if err := model.RemoveTagSnapshot(name); err != nil {
			return err
		}
		fmt.Println("ok")
		return nil
	},
}

var repoCheckoutCmd = &cobra.Command{
	Use:   "checkout --id <id>",
	Short: "Checkout (rollback to) a snapshot",

View on GitHub (pinned to 9f775e8a12)