Skip to content

[BUG]: github_branch_default resource fails on creation with rename set to true #1904

@stefan-hartmann-lgs

Description

@stefan-hartmann-lgs

Expected Behavior

If I have the following terraform config ...

resource "github_repository" "example" {
  name        = "example"
  auto_init   = true
}

resource "github_branch_default" "default"{
  repository = github_repository.example.name
  branch     = "main"
  rename     = true
}

... I expect the github_default_branch resource being created without issues.

Actual Behavior

The terraform plan succeeds without issues BUT on the terraform apply aka the creation of the github_default_branch resource an API call is made to rename the default branch from main to main. This API call fails with status code 422.

Doing an API call to rename main to main does not really make sense, fails and is an additional call which is not required.

A small condition only doing the rename-call if it makes sense would fix the issue aka if current_name != new_name.

See:

Terraform Version

Terraform v1.5.7
on linux_amd64

  • provider registry.terraform.io/integrations/github v5.36.0

Affected Resource(s)

  • github_branch_default

Terraform Configuration Files

No response

Steps to Reproduce

No response

Debug Output

No response

Panic Output

image

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleUsed by stalebot to clean houseStatus: Up for grabsIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documented

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions