You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Branch protection rule failed to be created with new format Github repository node_id #908
With Github migrating the repository's GraphQL global node ID to new format, branch protection rule resource cannot be created with node_id because the new format of node ID is no longer encoded by Base64.
Branch protection rule setup with repository name is still working correctly without being affected.
Terraform Version
0.14.11
Affected Resource(s)
github_branch_protection
Terraform Configuration Files
resource"github_repository""new_example_repo" {
name="new-example-repo"description="New Example Repo"
}
resource"github_branch_protection""example" {
repository_id=github_repository.new_example_repo.node_idpattern="main"enforce_admins=trueallows_deletions=true
}
Expected Behavior
Branch protection rule should be created in the new repository.
Actual Behavior
Error reported as following:
Error: Could not resolve to a Repository with the name 'owner/R_xxXXXXxxXx'.
on main.tf line 7, in resource "github_branch_protection" "example":
7: resource "github_branch_protection" "example" {
Steps to Reproduce
terraform apply
Reacted by Kevin Behrens, Clint Nelissen, Kurt McAlpine, Ryan King, Dee Kryvenko, Sascha, kflathers-chwy, Nathan, Peter Murray, bootswithdefer and 28 more
I'm also having this issue, but it seems weirdly intermittent. My module uses the repository node_id, which works for most repos, but every now and then I get the "could not resolve repository owner/<node_id>" error. If I can provide any additional information please let me know.
I've managed to work around this by adding some brute-force logic like so:
Reacted by Nate Dobbs, Dimitris Moraitidis, Bulat Saifullin, Brian A. Teller, Jai Govindani, Rotaru Sergey, Ashley Iris, Nicolai Antiferov, Austin Burdine and Omar Mendoza
The workaround mentioned doesn't work if your github_repository resource has a for_each loop in it. It attempts to change all of the existing branch protections repository_id to github_repository.repository.name.
Can we get some traction on this issue?
+1 on this, if you rename a repository, the name field will change, but the node_id should remain the same. Would be vastly preferable to continue using node_id everywhere.
This was mentioned in a PR that merged in November, but no release fixes it yet. Can we get an update on when we can expect to have this working, particularly for resources that include a loop? As noted by @ayk33, the ternary check doesn't work properly in a looping resource.
For folks still hitting this issue, I just wanted to share that I also got the same error response after mistakenly using the .id instead of the .node_id for referenced resources within a branch protection rule, ie. for cases where the repository_id was correct.
I fixed that and uses a correct user and it worked afterwards.
(Actually, I wanted to allow a specific GitHub App to bypass mandatory pull requests, so I fetched the node_id of that app using the github_app datasource instead).
Activity
yann-soubeyrand commentedon Sep 21, 2021
Hello, I’ve the same issue. In the meantime, using the name attribute of the github_repository resource seems to work.
logicbomb421 commentedon Sep 23, 2021
I'm also having this issue, but it seems weirdly intermittent. My module uses the repository
node_id, which works for most repos, but every now and then I get the "could not resolve repository owner/<node_id>" error. If I can provide any additional information please let me know.I've managed to work around this by adding some brute-force logic like so:
Use repository name as the repository_id for branch protection
rob-whittle commentedon Oct 1, 2021
Also hit this issue. Using this as a workaround for now:
ayk33 commentedon Nov 23, 2021
The workaround mentioned doesn't work if your
github_repositoryresource has afor_eachloop in it. It attempts to change all of the existing branch protectionsrepository_idtogithub_repository.repository.name.Can we get some traction on this issue?
kylekurz commentedon Nov 24, 2021
+1 on this, if you rename a repository, the
namefield will change, but thenode_idshould remain the same. Would be vastly preferable to continue usingnode_ideverywhere.kylekurz commentedon Jan 20, 2022
This was mentioned in a PR that merged in November, but no release fixes it yet. Can we get an update on when we can expect to have this working, particularly for resources that include a loop? As noted by @ayk33, the ternary check doesn't work properly in a looping resource.
Perfectium0 commentedon Feb 4, 2022
I'm in the same boat as @ayk33 and @kylekurz. Please provide an update ASAP.
We've planned exponential growth for 2022, so this will become a critical blocker if not addressed.
fix: use name instead of node_id
TheKevJames commentedon Oct 25, 2022
For folks still hitting this issue, I just wanted to share that I also got the same error response after mistakenly using the
.idinstead of the.node_idfor referenced resources within a branch protection rule, ie. for cases where therepository_idwas correct.For example, I had the following:
which should instead be:
kfcampbell commentedon Oct 27, 2022
👋 hi! Is this still an issue with current versions of the provider? It looks like #914 may have resolved it.
WTPOptAxe commentedon Feb 20, 2023
I'm seeing the same error with
push_restrictionswhen using a team's node_id as of today still.multani commentedon Feb 22, 2023
I also had the same issue, trying to configure
pull_request_bypassers, something like:I turned out that I was using a wrong user identifier in the
pull_request_bypasserslist and the provider couldn't find the associated user.I found this by running Terraform with
TF_LOG=debug, which gave me this:I doubled checked the content using https://docs.github.com/en/graphql/overview/explorer and indeed it couldn't find the user.
I fixed that and uses a correct user and it worked afterwards.
(Actually, I wanted to allow a specific GitHub App to bypass mandatory pull requests, so I fetched the
node_idof that app using thegithub_appdatasource instead).thomascrowley commentedon Feb 24, 2023
v5.18.0 fixed the similar issue I was getting for
pull_request_bypasserskfcampbell commentedon Mar 31, 2023
Closing this issue as it appears resolved. Please reopen with a descriptive comment if that's not the case!