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
provider wants to endlessly change the branches attribute of github_repository resource when repo is archived #1037
What the title says basically. The provider keeps trying to change the branches attribute of the github_repository resource, when the repo is archived. Even after applying, which outputs no error, the drift persists.
# module.repo_test-repo.github_repository.r will be updated in-place
~ resource "github_repository" "r" {
+ branches = (known after apply)
id = "$redacted"
name = "$redacted"
# (28 unchanged attributes hidden)
}
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
import an archived repo (or archive it after creating it via terraform)
plan
see drift being outputted
issue is mitigated when branches is included in the ignore_changes array, but this could lead to other issues too
Reacted by Rick van den Hof, Laertis Loutsis, Wagner One, Marco Molteni, Tom Murphy, Jackson, Kevin Behrens, Yann Soubeyrand, Steve Brown, Stefan Parviainen and 22 more
Looking at a diff between a repository terraform repeatedly wants to add "branches" to vs. one it actually put "branches" into, the one it added it to has attribute "auto_init" and it's set to "false". The repo it keeps asking to add "branches" to does not have attribute "auto_init". -- This seems to be a red herring as I found another problematic repo that does have "auto_init" attribute set and no "branches" set.
Reacted by Fionn Masuhr, Kevin Behrens, Johannes Grumböck, Julian Tölle, Marco Molteni, Dion Gionet Mallet, Christian Jensen, Nathan J Mehl, Miran, Mark Adamson and 1 more
I'm guessing this was introduced in 4.19.0 given the changelog mentions Export branches attribute of github_repository resource.
Sure enough attempting to upgrade from 4.16.0 -> 4.19.0 results in the same behaviour others are seeing (with both archived and normal repos).
Given we have some 400 repos we've decided not to update all their resources and have instead pinned to 4.18.2 until this gets resolved.
After upgrading provider to 4.19.1 we are seeing the same issue with normal, un-archived repositories.
Workaround we have for now is adding :
lifecycle {
ignore_changes = [
branches,
]
}
in resource "github_repository" "repos" {...}
Terraform v1.0.11 on linux_amd64
Sorry - I had to downvote this answer as it is a hack. We really need this fixed as we have 500+ repositories managed and adding this 500+ times and then removing once the bug is fixed is a non-starter.
Reacted by Kamran Farhadi, Fionn Masuhr, Benedikt Böhm, Nathan J Mehl, Steve Brown, Peiman Jafari, Jason Harper, georgekaz, Maciej Pasternacki, Iiro Niinikoski and 1 more
Adding on additional information to the sentiment that the ignore_changes workaround is insufficient. Thanks to hashicorp/terraform#30517, Terraform now slaps the user's hand for ignoring a computed attribute (branches in this case).
╷
│ Warning: Redundant ignore_changes element
│
│ on < redacted > line 1, in resource "github_repository" "this":
│ 1: resource "github_repository" "this" {
│
│ Adding an attribute name to ignore_changes tells Terraform to ignore future changes to the argument in configuration after the object has been created, retaining the
│ value originally configured.
│
│ The attribute branches is decided by the provider alone and therefore there can be no configured value to compare with. Including this attribute in ignore_changes has
│ no effect. Remove the attribute from ignore_changes to quiet this warning.
@dimisjim , @k24dizzle , @kfcampbell it seems after merging #1117 fixes this issue, could you confirm? I see this issue still open, so I'm not sure on how it is going.
@Esysc thanks for the poke; I had neglected to close this issue. You're correct that #1117 should resolve this behavior, and any further issues can be opened separately.
Activity
wagnerone commentedon Jan 18, 2022
I'm seeing this on normal, unarchived repositories too.
The first pass I did terraform wanted to add "branches" attribute to 191 repos and subsequent passes it wants to add "branches" to 92 repos.
Terraform v1.1.3
on darwin_arm64
Looking at a diff between a repository terraform repeatedly wants to add "branches" to vs. one it actually put "branches" into, the one it added it to has attribute "auto_init" and it's set to "false". The repo it keeps asking to add "branches" to does not have attribute "auto_init". -- This seems to be a red herring as I found another problematic repo that does have "auto_init" attribute set and no "branches" set.
dimisjim commentedon Jan 18, 2022
Interesting. The archived repos in our case, have indeed the auto_init attribute set to true, so it could be correlated
aliculPix4D commentedon Jan 20, 2022
After upgrading provider to
4.19.1we are seeing the same issue with normal, un-archived repositories.Workaround we have for now is adding :
in
resource "github_repository" "repos" {...}Terraform v1.0.11
on linux_amd64
shoddyguard commentedon Feb 1, 2022
I'm guessing this was introduced in
4.19.0given the changelog mentionsExport branches attribute of github_repository resource.Sure enough attempting to upgrade from
4.16.0->4.19.0results in the same behaviour others are seeing (with both archived and normal repos).Given we have some 400 repos we've decided not to update all their resources and have instead pinned to
4.18.2until this gets resolved.Workaround for integrations/terraform-provider-github#1037
Ignore branches tag due to upgrade in GitHub Terraform provider
Workaround for integrations/terraform-provider-github#1037
jensenbox commentedon Mar 9, 2022
Sorry - I had to downvote this answer as it is a hack. We really need this fixed as we have 500+ repositories managed and adding this 500+ times and then removing once the bug is fixed is a non-starter.
k24dizzle commentedon Mar 22, 2022
#1010
Related issue ^
MrBlaise commentedon Mar 31, 2022
I have migrated from the deprecated hashicorp/github provider to integrations/github and this started happening for me too.
k24dizzle commentedon Apr 18, 2022
I gave a shot to fix this issue here: #1117
Would appreciate any feedback on the best ways to potentially roll this change out.
StephenWithPH commentedon Jul 1, 2022
Adding on additional information to the sentiment that the ignore_changes workaround is insufficient. Thanks to hashicorp/terraform#30517, Terraform now slaps the user's hand for ignoring a computed attribute (
branchesin this case).PrzemyslawZieja commentedon Jul 19, 2022
We still have sort of an issue with ignoring branches (version 1.2.5). In part of our code, we use a loop to bulk create repositories
In such case, running
terraform planresults in plan containing changes in branches. Update to following form:generates warning
It looks like changes in branches are not properly ignored.
gastaldi commentedon Aug 17, 2022
Any ETA when this will be fixed? The
Warning: Redundant ignore_changes elementis really annoyingmaciejp-ro commentedon Sep 15, 2022
Does 5.0 version close this issue by eliminating
branches?Esysc commentedon Oct 4, 2022
@dimisjim , @k24dizzle , @kfcampbell it seems after merging #1117 fixes this issue, could you confirm? I see this issue still open, so I'm not sure on how it is going.
kfcampbell commentedon Oct 10, 2022
@Esysc thanks for the poke; I had neglected to close this issue. You're correct that #1117 should resolve this behavior, and any further issues can be opened separately.
Remove the lifecycle hack for branches