siyuan-note/siyuan · error
--new is required
Error message
--new is required
What it means
Argument validation in the cobra tagRename RunE: fires when the --new flag is empty after --old passed. Renaming a tag requires both the current label (--old) and the replacement label (--new); supplying only --old is the faulting usage.
Solutions
- Add the target: `siyuan tag rename --old oldtag --new newtag`
- Ensure the new label is non-empty and correctly quoted
- Confirm flag order and spelling (`--new`, not `--label`)
Example fix
// before siyuan tag rename --old oldtag // after siyuan tag rename --old oldtag --new newtag
Defensive patterns
Strategy: validation
Validate before calling
if [ -z "$NEW" ]; then echo "--new is required" >&2; exit 2; fi siyuan tag rename --old "$OLD" --new "$NEW"
Try / catch
if ! siyuan tag rename --old "$OLD" --new "$NEW"; then echo "rename failed; check --new value" >&2 fi
Prevention
- Never leave --new empty; a rename needs an explicit target
- Quote flag values to survive shell splitting
- Double-check flag names: --old and --new, not --label
When it happens
Trigger: Running `siyuan tag rename --old oldtag` without `--new`, or with `--new ""`.
Common situations: Forgetting the second flag in interactive use; empty result from a script variable that computes the new name; truncation of a long 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
- --label is required
- --old is required
- --av and --ids are required
- --av, --key, --item and --value are required
- --block is required for non-detached rows
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/2bae2cfdf95cc7c2.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/cli/cmd/tag.go:85
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",
RunE: func(cmd *cobra.Command, args []string) error {
oldLabel, _ := cmd.Flags().GetString("old")
newLabel, _ := cmd.Flags().GetString("new")
if oldLabel == "" {
return fmt.Errorf("--old is required")
}
if newLabel == "" {
return fmt.Errorf("--new is required")
}
if dryRun {
fmt.Printf("[dry-run] Would rename tag \"%s\" to \"%s\"\n", oldLabel, newLabel)
return nil
}
if err := model.RenameTag(oldLabel, newLabel); err != nil {
return err
}
model.AppendPushReloadTagEntry()
return nil
},
}
func printTagTable(tags []string) {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintln(w, "LABEL")View on GitHub (pinned to 9f775e8a12)