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

weird behavior of allow_forking for orgs with forking disabled #1136

Closed
oprudkyi opened this issue Apr 29, 2022 · 6 comments · Fixed by #1137
Closed

weird behavior of allow_forking for orgs with forking disabled #1136

oprudkyi opened this issue Apr 29, 2022 · 6 comments · Fixed by #1137

Comments

@oprudkyi
Copy link

Hi there,

Terraform Version

Terraform v1.1.9

Affected Resource(s)

  • github_repository

Terraform Configuration Files

resource "github_repository" "repository" {
  for_each = var.repositories
  name     = each.key

  description          = each.value.description
  homepage_url         = each.value.homepage_url
  allow_merge_commit   = each.value.allow_merge_commit
  allow_rebase_merge   = each.value.allow_rebase_merge
  allow_squash_merge   = each.value.allow_squash_merge
  has_downloads        = each.value.has_downloads
  has_issues           = each.value.has_issues
  has_projects         = each.value.has_projects
  has_wiki             = each.value.has_wiki
  vulnerability_alerts = each.value.vulnerability_alerts
  visibility           = each.value.visibility == null ? "private" : each.value.visibility

  lifecycle {
    ignore_changes = [
      # branches are very slow to update and unused anyway
      branches,
    ]
  }
}

Expected Behavior

  • use value from repository by default when there no such field in definition

Actual Behavior

  • errors, need to rerun apply to remove errors

Steps to Reproduce

Organization with forks disabled, private repository, 4.23.0 of provider

then update provider (without adding allow_forking) and apply

Error: PATCH https://api.github.com/repos/org/repo: 422 This organization does not allow private repository forking []

  with github_repository.repository["repo"],
  on github-main.tf line 8, in resource "github_repository" "repository":
   8: resource "github_repository" "repository" {

but if run apply second time - everything is fine (and state has allow_forking == true, while really forking is disabled)

then if I disable allow_forking explicitly the error returns

allow_forking        = false # forcefully disable forks

output

Error: PATCH https://api.github.com/repos/org/repo: 422 This organization does not allow private repository forking []

  with github_repository.repository["repo"],
  on github-main.tf line 8, in resource "github_repository" "repository":
   8: resource "github_repository" "repository" {

but again if run apply second time , then everything is fine

References

#1033
@kfcampbell @diogopms

@sksat
Copy link

sksat commented Apr 29, 2022

I have the same problem...(on organization repository and my personal repository)

@Ka1wa
Copy link

Ka1wa commented Apr 29, 2022

Not much to add to the original issue here. Very much in the same boat, we tried rolling back to an older provider version but that is also giving headaches because of the massive amounts of repositories we manage.

@uportalis
Copy link

Same problem for me. This prevents me to create a new repository with terraform because, even when I run plan/apply twice.
I had to temporary allow forking private repositories for my organization to make the plan/apply success (and switched it back to disallow right after).

@davidfleming
Copy link

Running into this issue as well. I would expect it to default to false which is the same functionality as the UI. Looking through the API I don't see anywhere that explicitly states that it defaults to true. In fact it doesn't appear to be documented for create -> https://docs.github.com/en/rest/repos/repos#create-an-organization-repository

@tomazellifelipe
Copy link

Same problem here.

@kfcampbell
Copy link
Member

Sorry about that folks! I've reverted the offending PR and published v4.24.1 with only that change in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants