-
Notifications
You must be signed in to change notification settings - Fork 949
[BUG]: Inconsistent result when moving from github_organization_custom_role to github_organization_repository_role #2805
Copy link
Copy link
Closed
Labels
Type: BugSomething isn't working as documentedSomething isn't working as documented
Milestone
Description
Expected Behavior
The github_organization_repository_role resource should be created successfully on the first terraform apply and tracked correctly in state, allowing subsequent applies to be idempotent.
Actual Behavior
On the first apply, Terraform fails with: Provider produced inconsistent result after apply: Root object was present, but now absent. Despite the error, the role is actually created in GitHub.
A second apply fails with: 422 Name has already been taken
because Terraform attempts to recreate the role it failed to record in state.
Terraform Version
Terraform v1.11.1
on darwin_arm64
- provider registry.terraform.io/integrations/github v6.7.0
Affected Resource(s)
- github_organization_repository_role
Terraform Configuration Files
repository_roles = {
"codeowner" = {
description = "Maintain plus bypass branch protection and resolve scanning alerts"
base_role = "maintain"
permissions = [
"bypass_branch_protection",
"delete_alerts_code_scanning",
"resolve_secret_scanning_alerts",
"view_secret_scanning_alerts",
]
}
"developer" = {
description = "Write plus view secret scanning alerts"
base_role = "write"
permissions = ["view_secret_scanning_alerts"]
}
}
resource "github_organization_repository_role" "this" {
for_each = var.repository_roles
name = each.key
description = each.value.description
base_role = each.value.base_role
permissions = each.value.permissions
}Steps to Reproduce
$ terraform apply
Debug Output
Panic Output
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to module.org.github_organization_repository_role.this["developer"], provider "provider[\"registry.terraform.io/integrations/github\"]" produced an unexpected new value: Root object was present, but now absent.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: error creating GitHub organization repository role (prisamedia-training-sandbox/developer): POST https://api.github.com/orgs/prisamedia-training-sandbox/custom-repository-roles: 422 Name has already been taken []
│
│ with module.org.github_organization_repository_role.this["developer"],
│ on ../../modules/github-organization/main.tf line 98, in resource "github_organization_repository_role" "this":
│ 98: resource "github_organization_repository_role" "this" {
│
╵Code of Conduct
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type: BugSomething isn't working as documentedSomething isn't working as documented
Type
Projects
Status
✅ Done
Status
Done