siyuan-note/siyuan · error

--id and --name are required

Error message

--id and --name are required

What it means

The `siyuan repo tag` command tags a repo snapshot and requires both `--id` (snapshot ID) and `--name` (tag name). The RunE handler returns this error when either flag is empty, before dry-run handling or the tagging call.

Solutions

  1. Re-run with both flags: `siyuan repo tag --id <snapshotID> --name <tagName>`
  2. Echo the variables in your script to confirm both snapshot ID and tag name are set
  3. List available snapshots first to obtain a valid --id

Example fix

// before
siyuan repo tag --id 20240101120000-abcdefg
// after
siyuan repo tag --id 20240101120000-abcdefg --name v1
Defensive patterns

Strategy: validation

Validate before calling

[ -n "$SNAP_ID" ] && [ -n "$TAG_NAME" ] || { echo "repo tag: need --id and --name" >&2; exit 2; }
siyuan repo tag --id "$SNAP_ID" --name "$TAG_NAME"

Type guard

function requireBoth(a, b, names) { if (!a || !b) throw new Error(names.join(' and ') + ' are required'); }

Try / catch

siyuan repo tag --id "$SNAP_ID" --name "$TAG_NAME" || { echo 'verify both --id and --name were provided'; }

Prevention

When it happens

Trigger: Running `siyuan repo tag` missing `--id`, missing `--name`, or both; e.g. `siyuan repo tag --id <snapshotID>` without `--name v1`.

Common situations: Assuming the tag alone identifies the snapshot (both are required); scripts that only fill one variable; typos in flag names silently yielding empty values.

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/271c8bf0d5379376. Report an issue: GitHub.

Appendix: source

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

			return err
		}
		if created {
			fmt.Println("created snapshot", id)
		} else {
			fmt.Println("no changes; existing snapshot", id)
		}
		return nil
	},
}

var repoTagCmd = &cobra.Command{
	Use:   "tag --id <id> --name <name>",
	Short: "Tag a snapshot",
	RunE: func(cmd *cobra.Command, args []string) error {
		id, _ := cmd.Flags().GetString("id")
		name, _ := cmd.Flags().GetString("name")
		if id == "" || name == "" {
			return fmt.Errorf("--id and --name are required")
		}

		if dryRun {
			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",

View on GitHub (pinned to 9f775e8a12)