Skip to content

weird behavior of allow_forking for orgs with forking disabled #1136

@oprudkyi

Description

@oprudkyi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions