Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
Trikenstein opened this issue May 21, 2024 · 1 comment
Open
1 task done
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented

Comments

@Trikenstein
Copy link

Trikenstein commented May 21, 2024

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
@Trikenstein Trikenstein added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels May 21, 2024
@o-sama
Copy link
Contributor

o-sama commented May 21, 2024

I'm aware of this issue but the limitation actually lies in the go-github client, last I checked was a few months ago and the issue still existed. I'll check in the next few days and if it's been fixed I'll make the change to fix this here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

2 participants