integrations / terraform-provider-github

Terraform GitHub provider
https://www.terraform.io/docs/providers/github/
MIT License
888 stars 729 forks source link

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

Open ezzatron opened 8 months ago

ezzatron commented 8 months ago

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)

Terraform Configuration Files

No response

Steps to Reproduce

No response

Debug Output

No response

Panic Output

No response

Code of Conduct