siyuan-note/siyuan · error
--old is required
Error message
--old is required
What it means
Argument validation in the cobra tagRename RunE: fires when the --old flag is empty (the --new check follows). Renaming a tag requires the existing label; supplying only --new or no flags is the faulting usage.
Solutions
- Provide both flags: `siyuan tag rename --old oldtag --new newtag`
- Verify the old tag exists via a tag listing before renaming
- Ensure shell variables for old/new are non-empty
Example fix
// before siyuan tag rename --new newtag // after siyuan tag rename --old oldtag --new newtag
Defensive patterns
Strategy: validation
Validate before calling
if [ -z "$OLD" ]; then echo "--old 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; verify both flags" >&2 fi
Prevention
- Supply both --old and --new in every invocation
- Validate both variables before running
- Keep a tag listing handy to copy exact current labels
When it happens
Trigger: Running `siyuan tag rename` without `--old`, or with `--old ""`.
Common situations: Providing only `--new` assuming rename infers the source; quoting mistakes that drop the flag value; scripting where the old-label variable is empty.
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
- --new 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/ad2b8ea315abfc46.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/cli/cmd/tag.go:82
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",
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
},
}
View on GitHub (pinned to 9f775e8a12)