Repository navigation
Closed
Description
GitHub recently added the ability to put GitHub Apps in the branch protection exception list so the GitHub App can bypass branch protection rules. This is useful if I want to drop GitHub Action workflow templates into repos in my organization without requiring a PR, or use the FluxCD provider to bootstrap flux manifests in repos.
However, when I tested this new feature I noticed it caused an error when Terraform attempted to create the plan.
As soon as I removed the GitHub App from the branch protection rule exception list, the plan worked correctly again.
Terraform Version
# terraform -v
Terraform v1.1.8
on linux_amd64Affected Resource(s)
- github_branch_protection
Terraform Configuration Files
resource "github_branch_protection" "this" {
for_each = { for branch in local.settings.protected_branches : branch.pattern => branch }
repository_id = github_repository.this.node_id
pattern = each.value.pattern
enforce_admins = try(each.value.enforce_admins, true)
allows_deletions = try(each.value.allows_deletions, false)
allows_force_pushes = try(each.value.allows_force_pushes, false)
required_linear_history = try(each.value.required_linear_history, false)
require_conversation_resolution = try(each.value.require_conversation_resolution, true)
required_pull_request_reviews {
dismiss_stale_reviews = try(each.value.dismiss_stale_reviews, true)
required_approving_review_count = try(each.value.required_approving_review_count, 1)
require_code_owner_reviews = try(each.value.require_code_owner_reviews, false)
pull_request_bypassers = try(data.github_users.pull_request_bypassers[each.key].node_ids, [])
}
required_status_checks {
strict = try(each.value.strict, true)
contexts = each.value.contexts
}
}Expected Behavior
A plan should have been created.
Actual Behavior
╷
│ Error: Something went wrong while executing your query. Please include `0681:9080:C14D4:D695D:62879F7D` when reporting this issue.
│
│ with module.repos["flux-system"].github_branch_protection.this["main"],
│ on ../modules/gh-repo/main.tf line 63, in resource "github_branch_protection" "this":
│ 63: resource "github_branch_protection" "this" {
│
╵
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
- Add the provider GitHub App to a branch protection exception list on a repo.
- Attempt to plan that will trigger a
GETon the branch protection rules (github_branch_protectionresource) terraform plan
Reacted by Julien Michaud, Noah Stride and Marcel
Metadata
Metadata
Assignees
Labels
No labels
Activity
vgrigoruk commentedon Jun 23, 2022
I experienced the same issue today. After a small investigation I've found out that
Github appswere not added in the original PR which added support forpull_request_bypassersattribute:https://github.com/integrations/terraform-provider-github/pull/1030/files#diff-b5b3ae3d317e4c199b2bc55f4806ecb01a0f7764638d573587d9d680229145b9R23-R29
devopsrick commentedon Jun 27, 2022
Yeah github apps weren't an option when this feature was rolled out.
github-actions commentedon Mar 25, 2023
👋 Hey Friends, this issue has been automatically marked as
stalebecause it has no recent activity. It will be closed if no further activity occurs. Please add theStatus: Pinnedlabel if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!paymand commentedon Mar 25, 2023
Looks like this was implemented here: #1453
And the fix was released in https://github.com/integrations/terraform-provider-github/releases/tag/v5.13.0
This issue can be closed I think.
julien-michaud commentedon Mar 27, 2023
still getting error
Error: Could not resolve to a node with the global id of ''when trying to allow a GitHub App to bypass branch protection.kfcampbell commentedon Apr 10, 2023
@julien-michaud do you mind creating a new issue with an appropriate description and a snippet of HCL to reproduce it?
mering commentedon Jul 7, 2023
@julien-michaud did you create a new issue?
In case anyone else arrives here , I found help for this error in #1248.
Invincibear commentedon Sep 3, 2025
@mering THANK YOU!
To save somebody else, this worked for me:
You might need to enable
readEnterprise -> Enterprise organization installations permission on whatever you're using to auth Terraform with GitHub