{"record":{"id":"ad2b8ea315abfc46","repo":"siyuan-note/siyuan","slug":"old-is-required-ad2b8e","errorCode":null,"errorMessage":"--old is required","messagePattern":"--old is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/tag.go","lineNumber":82,"sourceCode":"\t\t\treturn nil\n\t\t}\n\n\t\tif err := model.RemoveTag(label); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmodel.AppendPushReloadTagEntry()\n\t\treturn nil\n\t},\n}\n\nvar tagRenameCmd = &cobra.Command{\n\tUse:   \"rename --old <old-label> --new <new-label>\",\n\tShort: \"Rename a tag\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\toldLabel, _ := cmd.Flags().GetString(\"old\")\n\t\tnewLabel, _ := cmd.Flags().GetString(\"new\")\n\t\tif oldLabel == \"\" {\n\t\t\treturn fmt.Errorf(\"--old is required\")\n\t\t}\n\t\tif newLabel == \"\" {\n\t\t\treturn fmt.Errorf(\"--new is required\")\n\t\t}\n\n\t\tif dryRun {\n\t\t\tfmt.Printf(\"[dry-run] Would rename tag \\\"%s\\\" to \\\"%s\\\"\\n\", oldLabel, newLabel)\n\t\t\treturn nil\n\t\t}\n\n\t\tif err := model.RenameTag(oldLabel, newLabel); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmodel.AppendPushReloadTagEntry()\n\t\treturn nil\n\t},\n}\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/tag.go#L64-L100","documentation":"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.","triggerScenarios":"Running `siyuan tag rename` without `--old`, or with `--old \"\"`.","commonSituations":"Providing only `--new` assuming rename infers the source; quoting mistakes that drop the flag value; scripting where the old-label variable is empty.","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"],"exampleFix":"// before\nsiyuan tag rename --new newtag\n// after\nsiyuan tag rename --old oldtag --new newtag","handlingStrategy":"validation","validationCode":"if [ -z \"$OLD\" ]; then echo \"--old is required\" >&2; exit 2; fi\nsiyuan tag rename --old \"$OLD\" --new \"$NEW\"","typeGuard":null,"tryCatchPattern":"if ! siyuan tag rename --old \"$OLD\" --new \"$NEW\"; then\n  echo \"rename failed; verify both flags\" >&2\nfi","preventionTips":["Supply both --old and --new in every invocation","Validate both variables before running","Keep a tag listing handy to copy exact current labels"],"tags":["cli","tag","missing-flag"],"backgroundTag":"missing-required-flag","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}