Skip to content

[BUG]: github_issue_labels can't clobber existing labels #2089

Closed

Description

@ezzatron

Expected Behavior

I expected the github_issue_labels resource to allow me to specify the full list of issue labels I want, even if those issue labels overlap some of the default ones created in a new GitHub repo, or include other existing labels in the repo.

Actual Behavior

When using github_issue_labels with a set of labels that includes an existing label, the apply fails with an error like:

{"@level":"error","@message":"Error: POST https://api.github.com/repos/org/repo/labels: 422 Validation Failed [{Resource:Label Field:name Code:already_exists Message:}]","@module":"terraform.ui","@timestamp":"2024-01-10T04:48:36.512181Z","diagnostic":{"severity":"error","summary":"POST https://api.github.com/repos/org/repo/labels: 422 Validation Failed [{Resource:Label Field:name Code:already_exists Message:}]","detail":"","address":"module.name.github_issue_labels.this","range":{"filename":"modules/repo/issue-labels.tf","start":{"line":8,"column":39,"byte":246},"end":{"line":8,"column":40,"byte":247}},"snippet":{"context":"resource \"github_issue_labels\" \"this\"","code":"resource \"github_issue_labels\" \"this\" {","start_line":8,"highlight_start_offset":38,"highlight_end_offset":39,"values":[]}},"type":"diagnostic"}

This makes it impossible to use this resource with a set of labels that includes any of the default labels for new repos. This would be fine if you could simply omit those labels, but if you do, the default labels will be removed on subsequent runs.

Terraform Version

Terraform v1.6.6
on darwin_arm64
+ provider registry.terraform.io/integrations/github v5.43.0

Affected Resource(s)

  • github_issue_labels

Terraform Configuration Files

No response

Steps to Reproduce

No response

Debug Output

No response

Panic Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    Status: TriageThis is being looked at and prioritized
    Type: BugSomething isn't working as documented
    on Jan 10, 2024
  2. added
    Status: Up for grabsIssues that are ready to be worked on by anyone
    and removed
    Status: TriageThis is being looked at and prioritized
    on Jan 18, 2024
  3. moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Activeon Jan 18, 2024
  4. github-actions commented on Oct 15, 2024

    @github-actions

    👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

  5. ezzatron commented on Oct 15, 2024

    @ezzatron
    Author

    As far as I'm aware this is still an issue.

  6. larsks commented on Feb 6, 2025

    @larsks

    I just ran into this myself; it makes the provider just about useless. We've had to switch to using github_issue_label instead, which while it works means we're now managing individual labels rather than an exclusive set.

    I see there's been a pull request in place since October that looks like it addresses the problem; it would be awesome if that could get merged.

    Thanks @stevehipwell for tackling this.

  7. fatbasstard commented on Mar 25, 2025

    @fatbasstard
    Contributor

    Let me chip in. I want to start controlling the labels as well which is pretty much impossible due to the default tags.

    Workaround is to either use import or change the organisational labels configuration to manupilate the tags of new repositories so they don't collide.

    For a "maintain all labels of a repositories" resource a solution could be to automatically adopt all existing labels automatically and just take full control.

    There are other resources that behave like this, e.g. aws_securityhub_standards_control_association

  8. stevehipwell commented on Mar 25, 2025

    @stevehipwell
    Collaborator

    @fatbasstard #2430 fixes this and adds tests (5+ months ago) but hasn't even been acknowledged by the maintainers.

  9. fatbasstard commented on Mar 25, 2025

    @fatbasstard
    Contributor

    @kfcampbell @nickfloyd Do you have any time to take a look at this issue and related PR #2430

  10. 1 remaining item

  11. ezzatron commented on Apr 23, 2025

    @ezzatron
    Author

    The workaround I'm currently using is to remove the default labels at the organization level, so that new repos created by Terraform get no labels at all. Then I'm free to set whatever labels I want with github_issue_labels.

    Unfortunately this only works for organizations, as far as I know: https://docs.github.com/en/organizations/managing-organization-settings/managing-default-labels-for-repositories-in-your-organization#deleting-a-default-label

  12. JvdsReform commented on May 19, 2025

    @JvdsReform

    Is this fixed? I ran terraform plan and saw that my existing labels were being removed, like the resource should do.

  13. esacteksab commented on May 20, 2025

    @esacteksab

    Yeah, I'm seeing similar behavior. More aligned with expectations. No change in the provider (v6.6.0).

  14. moved this from Backlog to On Deck in Terraform Provideron Oct 14, 2025
  15. moved this from On Deck to In Review in Terraform Provideron Oct 20, 2025
  16. moved this from 🔥 Backlog to ✅ Done in 🧰 Octokit Activeon Oct 20, 2025
  17. NickLarsenNZ commented on Nov 11, 2025

    @NickLarsenNZ

    I've imported the labels for a repository, but the apply wants to first delete them, and then create them (exactly the same as they are).

    Slightly different to the original issue description but could it be related or should I open a new issue?

  18. stevehipwell commented on Nov 11, 2025

    @stevehipwell
    Collaborator

    @NickLarsenNZ which provider version and could you please share the output?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Up for grabsIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documented

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions