{"record":{"id":"10db0f4c21f2ec5c","repo":"cli/cli","slug":"label-with-name-q-already-exists","errorCode":null,"errorMessage":"label with name %q already exists","messagePattern":"label with name %q already exists","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/label/edit.go","lineNumber":92,"sourceCode":"\nfunc editRun(opts *editOptions) error {\n\thttpClient, err := opts.HttpClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\tapiClient := api.NewClientFromHTTP(httpClient)\n\n\tbaseRepo, err := opts.BaseRepo()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\topts.IO.StartProgressIndicator()\n\terr = updateLabel(apiClient, baseRepo, opts)\n\topts.IO.StopProgressIndicator()\n\tif err != nil {\n\t\tif errors.Is(err, errLabelAlreadyExists) {\n\t\t\treturn fmt.Errorf(\"label with name %q already exists\", opts.NewName)\n\t\t}\n\t\treturn err\n\t}\n\n\tif opts.IO.IsStdoutTTY() {\n\t\tcs := opts.IO.ColorScheme()\n\t\tsuccessMsg := fmt.Sprintf(\"%s Label %q updated in %s\\n\", cs.SuccessIcon(), opts.Name, ghrepo.FullName(baseRepo))\n\t\tfmt.Fprint(opts.IO.Out, successMsg)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":74,"sourceCodeEnd":105,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/pkg/cmd/label/edit.go#L74-L105","documentation":"Thrown by `gh label edit` when renaming a label to a name that already exists. updateLabel returns the sentinel errLabelAlreadyExists (GitHub rejects a rename onto an existing label name), and the command surfaces it naming opts.NewName, the requested new name.","triggerScenarios":"Calling `gh label edit <old-name> --name <new-name>` where <new-name> (case-insensitive) is already taken by another label in the repository. Also triggered when --name is omitted... only if opts.NewName collides; in practice it fires on rename collisions detected by the API.","commonSituations":"Label taxonomy cleanups that merge two labels by renaming one onto the other; automation that 'normalizes' label casing ('Bug' -> 'bug' when 'bug' exists); partial migrations re-run after failure.","solutions":["Pick a new name that no label currently uses; list candidates first with `gh label list --json name --jq '.[].name'`.","If the goal is merging labels, delete the target label first (`gh label delete <new-name> --yes`) then run the edit.","For case-only renames, first rename to a temporary name, then to the desired casing."],"exampleFix":"# before\ngh label edit \"help wanted\" --name \"good first issue\"\n# error: label with name \"good first issue\" already exists\n\n# after\ngh label delete \"good first issue\" --yes\ngh label edit \"help wanted\" --name \"good first issue\"","handlingStrategy":"validation","validationCode":"# before renaming, ensure the target name is free\nexisting=$(gh label list --json name --jq '.[].name' | grep -ixF \"$new_name\" || true)\n[ -n \"$existing\" ] && { echo \"label '$new_name' taken\" >&2; exit 2; }\ngh label edit \"$old_name\" --name \"$new_name\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fetch `gh label list --json name` and diff against your desired taxonomy before bulk renames.","For merges, delete the target label before renaming onto it.","For case-only renames, rename to a temporary name first."],"tags":["label","github-api","rename","cli"],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}