{"record":{"id":"2bae2cfdf95cc7c2","repo":"siyuan-note/siyuan","slug":"new-is-required-2bae2c","errorCode":null,"errorMessage":"--new is required","messagePattern":"--new is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/tag.go","lineNumber":85,"sourceCode":"\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\nfunc printTagTable(tags []string) {\n\tw := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)\n\tfmt.Fprintln(w, \"LABEL\")","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/tag.go#L67-L103","documentation":"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.","triggerScenarios":"Running `siyuan tag rename --old oldtag` without `--new`, or with `--new \"\"`.","commonSituations":"Forgetting the second flag in interactive use; empty result from a script variable that computes the new name; truncation of a long command line.","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`)"],"exampleFix":"// before\nsiyuan tag rename --old oldtag\n// after\nsiyuan tag rename --old oldtag --new newtag","handlingStrategy":"validation","validationCode":"if [ -z \"$NEW\" ]; then echo \"--new 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; check --new value\" >&2\nfi","preventionTips":["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"],"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"}