Skip to content

[BUG]: Inconsistent result when moving from github_organization_custom_role to github_organization_repository_role #2805

Closed

Description

@vmvarela

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

Activity

  1. added
    Type: Bug
    Status: Triage
    on Oct 23, 2025
  2. changed the title [-][BUG]: Inconsistent result when moving from github_organization_custom_role to github_organization_repository_role[/-] [+][BUG]: Inconsistent result when moving from `github_organization_custom_role` to `github_organization_repository_role`[/+] on Oct 23, 2025
  3. nicolas-fidel-wmx commented on Oct 27, 2025

    @nicolas-fidel-wmx

    I have exactly the same problem.

  4. faust64 commented on Dec 4, 2025

    @faust64

    getting this too with v6.8.3, against GHES 3.17.7

  5. deiga commented on Dec 4, 2025

    @deiga
    Collaborator

    Hey @vmvarela 👋

    Thanks for reporting this!
    That definitely sounds wrong and needs fixing.

    We're currently focused on getting v7 of the provider released (which upgrades the Github SDK) and have limited capacity to address other issues.

    Once we're done, we'll look at prioritising the bugs and issues 😊

    In the meantime, if you'd like to take a stab at it and submit a PR, we'd appreciate that a lot!

  6. removed
    Status: Triage
    on Dec 4, 2025
  7. self-assigned this
    on Dec 4, 2025
  8. stevehipwell commented on Dec 4, 2025

    @stevehipwell
    Collaborator

    I suspect that this is due to the pattern of re-reading the resource after it's been created.

  9. moved this from Backlog to In Progress in Terraform Provideron Dec 4, 2025
  10. moved this from 🆕 Triage to ✅ Done in 🧰 Octokit Activeon Dec 5, 2025
  11. moved this from In Progress to Done in Terraform Provideron Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type: Bug

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions