integrations / integrations/terraform-provider-github

[BUG]: unable to add github apps to bypassers

Open
#2,236 26 comments 34 reactions 0 assignees View on GitHub
r/branch_protection Type: Bug
Dominant language
Go
Stars
1.2k
Forks
1k
Avg merge
1d 14h
Merged PRs (30d)
8

Description

### Expected Behavior

should be able to add a github app (bot) to PR bypassers, as indicated by the [docs](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/branch_protection#pull_request_bypassers);

> pull_request_bypassers: (Optional) The list of actor Names/IDs that are allowed to bypass pull request requirements. Actor names must either begin with a "/" for users or the organization name followed by a "/" for teams.

Can add a GitHub app using the GUI, but not in Terraform. When a GitHub app is manually added to the PR bypassers in the GUI, it shows up in terraform as [org name]/[app username].

NB This was tested within a GitHub org using a github app that had been granted all permissions.

### Actual Behavior

terraform apply returned the following error.

```
github_branch_protection.trunk_protection["test-trunk-protection"]: Modifying... [id=***]
github_branch_protection.trunk_protection["test-trunk-protection"]: Still modifying... [id=***, 10s elapsed]
github_branch_protection.trunk_protection["test-trunk-protection2"]: Still modifying... [id=***, 10s elapsed]

Error: Could not resolve to a node with the global id of ''

with github_branch_protection.trunk_protection["test-trunk-protection2"],
on github.tf line 38, in resource "github_branch_protection" "trunk_protection":
38: resource "github_branch_protection" "trunk_protection" {

Error: Could not resolve to a node with the global id of ''

with github_branch_protection.trunk_protection["test-trunk-protection"],
on github.tf line 38, in resource "github_branch_protection" "trunk_protection":
38: resource "github_branch_protection" "trunk_protection" {
```

fails when specifying github app as,
- [org name]/[app login] (the format returned by a `terraform plan`!)
- /[org name]/[app login]
- [app user id]
- /[app user login]
- /[app user login]`[bot]`
- [app installation id]

### Terraform Version

Terraform v1.8.0
GitHub provider v6.2.1

### Affected Resource(s)

github_branch_protection

### Terraform Configuration Files

```hcl
resource "github_branch_protection" "trunk_protection" {
pattern = "main"
repository_id = "test-trunk-protection"
...
required_pull_request_reviews {
pull_request_bypassers = compact(concat(
["/jamesgeddes"], # This human user works as expected.
))
}
}

resource "github_branch_protection" "trunk_protection2" {
pattern = "main"
repository_id = "test-trunk-protection2"
...
required_pull_request_reviews {
pull_request_bypassers = compact(concat(
["/jamesgeddes"], # This human user works as expected.
["geddesfamily/gedbot"], # As soon as this GitHub app is added, Terraform returns the aforementioned error.
))
}
}
```

### Steps to Reproduce

1. run `terraform plan` and `terraform apply` with no pull_request_bypassers
2. manually add github app to github branch protection gui
3. `terraform plan` shows [org name]/[app username] to remove
4. add [org name]/[app username] to terraform pull_request_bypassers
5. run `terraform plan` - note github app is accepted
6. run`terraform apply` - note `Error: Could not resolve to a node with the global id of ''` error

### Debug Output

_No response_

### Panic Output

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.