{"record":{"id":"779176418f495268","repo":"siyuan-note/siyuan","slug":"label-is-required-779176","errorCode":null,"errorMessage":"--label is required","messagePattern":"--label is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/tag.go","lineNumber":59,"sourceCode":"\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\tdata, _ := json.MarshalIndent(tags, \"\", \"  \")\n\t\t\tfmt.Println(string(data))\n\t\tdefault:\n\t\t\tprintTagTable(tags)\n\t\t}\n\t\treturn nil\n\t},\n}\n\nvar tagRemoveCmd = &cobra.Command{\n\tUse:   \"remove --label <label>\",\n\tShort: \"Remove a tag\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tlabel, _ := cmd.Flags().GetString(\"label\")\n\t\tif label == \"\" {\n\t\t\treturn fmt.Errorf(\"--label is required\")\n\t\t}\n\n\t\tif dryRun {\n\t\t\tfmt.Printf(\"[dry-run] Would remove tag \\\"%s\\\"\\n\", label)\n\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\",","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/tag.go#L41-L77","documentation":"Thrown by the `tag remove` cobra subcommand when `--label` is empty. The label is the tag string to delete via `model.RemoveTag(label)`. The guard runs before the model call (and before `--dry-run`) so an empty label never reaches the removal engine. After removal the CLI also pushes a tag-reload event.","triggerScenarios":"Running `siyuan tag remove` with no `--label`, or `--label \"\"`. Also if the flag is spelled differently so cobra leaves it at default.","commonSituations":"Forgetting the label token; assuming the tag is identified by an ID rather than its label string (SiYuan tags are keyed by label text); scripting removal and passing an unset shell variable.","solutions":["Pass the exact label text: `siyuan tag remove --label \"my-tag\"`.","List tags first to confirm the exact label: `siyuan tag list`.","Quote labels containing spaces."],"exampleFix":"// before\nsiyuan tag remove\n// after\nsiyuan tag remove --label \"reading\"","handlingStrategy":"validation","validationCode":"if label == \"\" {\n    fmt.Fprintln(os.Stderr, \"--label is required: pass the tag text\")\n    os.Exit(2)\n}\n// siyuan tag remove --label <label>","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Tags are keyed by label text, not an ID — pass the exact string.","Run `tag list` to confirm the label before removing.","Quote labels with spaces."],"tags":["cli","validation","tag","argument-required"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}