Skip to content

[BUG]: allow_forking seems to change on repo name update #3150

@Low-Frequency

Description

@Low-Frequency

Expected Behavior

Changing the name of a repo should not affect any other setting. Terraform plan seems fine.

Actual Behavior

When changing the name of a repo, terraform fails with the following error message:

PATCH https://api.github.com/repositories/: 422 Allow forks can only be changed on org-owned repositories []

There's no indication in the terraform plan, that this setting changes. Setting it explicitly to true, like it is in the terraform state doesn't change the behavior.

Terraform Version

Terraform v1.14.3
on linux_amd64

  • provider registry.terraform.io/integrations/github v6.10.2

Affected Resource(s)

  • github_repository

Terraform Configuration Files

Steps to Reproduce

main.tf:

terraform {
  required_version = "~> 1.14"
  required_providers {
    github = {
      source = "integrations/github"
      version = "~> 6.9"
    }
  }
}

variable "name" {
  type = string
}

resource "github_repository" "github_repo" {
  name = var.name
  visibility = "private"
  has_issues  = false
  has_discussions = false
  has_projects = false
  has_wiki = false
  archive_on_destroy = true

  ### Not set in initial test. Changing or omitting this doesn't affect the behavior
  allow_forking = true
}

terraform.tfvars:

name = "terraform-test"

### Change to this after initial apply to reproduce the error
# name = "terraform-test-01"

Terraform plan & apply:

$ terraform plan -out plan.tfplan
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create
  ~ update in-place
Terraform will perform the following actions:
  # github_repository.github_repo will be updated in-place
  ~ resource "github_repository" "github_repo" {
      ~ full_name                   = "Low-Frequency/terraform-test" -> (known after apply)
        id                          = "infrastructure-prod-on-prem-server-mariadb"
      ~ name                        = "terraform-test" -> "terraform-test-01"

Plan: 0 to add, 1 to change, 0 to destroy.

$ terraform apply -input=false plan.tfplan
github_repository.github_repo: Modifying... [id=terraform-test]
╷
│ Error: PATCH https://api.github.com/repositories/<ID>: 422 Allow forks can only be changed on org-owned repositories []
│ 
│   with github_repository.github_repo,
│   on .terraform/main.tf line 64, in resource "github_repository" "github_repo":
│   64: resource "github_repository" "github_repo" {
│ 
╵

Debug Output

Panic Output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working as documented

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions