{"record":{"id":"a21a11547859a5e6","repo":"siyuan-note/siyuan","slug":"new-is-required","errorCode":null,"errorMessage":"--new is required","messagePattern":"--new is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/bookmark.go","lineNumber":104,"sourceCode":"\t\tif err := model.RemoveBookmark(label); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmodel.AppendPushReloadFiletreeEntry()\n\t\treturn nil\n\t},\n}\n\nvar bookmarkRenameCmd = &cobra.Command{\n\tUse:   \"rename --old <old> --new <new>\",\n\tShort: \"Rename a bookmark\",\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 bookmark \\\"%s\\\" to \\\"%s\\\"\\n\", oldLabel, newLabel)\n\t\t\treturn nil\n\t\t}\n\n\t\tif err := model.RenameBookmark(oldLabel, newLabel); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmodel.AppendPushReloadFiletreeEntry()\n\t\treturn nil\n\t},\n}\n\nfunc printBookmarkTable(bookmarks *model.Bookmarks) {\n\tw := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)\n\tfmt.Fprintln(w, \"NAME\\tCOUNT\")","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/bookmark.go#L86-L122","documentation":"Argument validation in the cobra bookmarkRename RunE: fires when the --new flag is empty after --old passed. Renaming a bookmark requires both the existing label (--old) and the target label (--new); supplying only --old is the faulting usage.","triggerScenarios":"Running `bookmark rename --old \"TODO\"` without --new, or with `--new \"\"`; shell quoting issues that swallow the value (`--new \"$NEW\"` with NEW empty or containing only spaces).","commonSituations":"Bulk rename scripts where the new-label list is shorter than the old-label list; intending to clear/delete a bookmark via an empty new label (unsupported — use `bookmark remove` instead).","solutions":["Supply the target label: bookmark rename --old \"TODO\" --new \"Important\"","If the goal is deletion, use `bookmark remove --label <label>` instead of renaming to an empty string","Verify shell variables are quoted and non-empty before invoking the command"],"exampleFix":"// before\nsiyuan bookmark rename --old \"TODO\" --new \"\"\n// after\nsiyuan bookmark remove --label \"TODO\"","handlingStrategy":"validation","validationCode":"if [ -z \"$NEW\" ]; then echo \"--new is required (use bookmark remove to delete)\" >&2; exit 1; fi\nsiyuan bookmark rename --old \"$OLD\" --new \"$NEW\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat empty --new as a signal to use bookmark remove instead","Pair old/new labels in parallel arrays and check lengths match before batch renaming","Quote variables so whitespace-only values are caught"],"tags":["cli","missing-flag","bookmark","rename"],"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"}