Skip to content

[BUG]: github_repository_ruleset can create bypass_actors but cannot delete #2269

@Trikenstein

Description

@Trikenstein

Expected Behavior

Using Terraform provider integrations/github version 6.2.1

A github_repository_ruleset resource has been created with a bypass_actors attribute. Later on, the bypass_actors attribute is removed. The Terraform plan confirm the deletion:

# module.CITest.github_repository_ruleset.protection-on-default will be updated in-place
~ resource "github_repository_ruleset" "protection-on-default" {
     id          = "791751"
    name        = "Protections (Default Branch)"
    # (6 unchanged attributes hidden)

    - bypass_actors {
        - actor_id    = 123456789 -> null
        - actor_type  = "Team" -> null
        - bypass_mode = "always" -> null
      }
}

The Terraform apply confirm modification successful

module.CITest.github_repository_ruleset.protection-on-default: Modifications complete after 2s [id=791751]

Using Github UI on the "CITest" repo, Settings, Rules/Ruleset. Select the ruleset. The bypasser still exists.

Actual Behavior

Terraform apply was not able to delete the bypass_actors attribute. And yet the output showed the operation as successful. Re-running a Terraform plan shows the same "updated in-place" shown above. Which means the terraform apply did not change the github_repository_ruleset to remove the existing value in bypass_actors.

The workaround is to use Github UI to delete the bypasser manually.

Terraform Version

Terraform v1.8.3
on linux_amd64
+ provider registry.terraform.io/hashicorp/azurerm v3.103.1
+ provider registry.terraform.io/integrations/github v6.2.1

Affected Resource(s)

  • github_repository_ruleset, in particular the bypass_actors attribute

Terraform Configuration Files

resource "github_repository_ruleset" "protection-on-default" {
  name        = "Protections (Default Branch)"
  repository  = github_repository.repository.name
  target      = "branch"
  enforcement = "active"

  conditions {
    ref_name {
      include = ["~DEFAULT_BRANCH"]
      exclude = []
    }
  }

  rules {
    deletion                = true
    required_linear_history = true
    non_fast_forward        = true
  }

  bypass_actors {
    # actor_id get your team id by
    # curl -sSL -H "Authorization: Bearer $MY_GH_PAT" https://api.github.com/orgs/Tracktrace-NGTT/teams/myteam-name
    actor_id    = 123456789 
    actor_type  = "Team"
    bypass_mode = "always"
  }
}

Steps to Reproduce

  • 1st run : terraform apply the above code (
  • Verify in Github UI, Settings, Rules/Ruleset, that the bypass_actors was created correctly
  • 2nd run: comment out the bypass_actors block, then apply
  • check using Github UI (or rerun terraform plan) to confirm the bug (that bypass_actors was not deleted)

Debug Output

No response

Panic Output

No response

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working as documented

    Type

    No type

    Projects

    Status

    ✅ Done

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions