Skip to content

[BUG]: github_branch_default tries to rename Branch to same name #2829

@V0idC0de

Description

@V0idC0de

Expected Behavior

github_branch_default with rename = true ensures, that the default Branch is called as specified, renaming it, if required.

Actual Behavior

github_branch_default returns an error from the GitHub API, since /repos/<repo>/branches/<branch>/rename is invoked, even if the default branch already has the desired name. GitHub returns the following error line:
Error: POST https://api.github.com/repos/<repo>/branches/master/rename: 422 Validation Failed [{Resource: Field: Code: Message:New branch cannot be the same as the current branch}]

Note

The behavior is made more difficult by the fact, that a github_branch seemingly cannot be created in an empty Repository, as it uses a source_branch. This would ensure, that the empty Repository is populated with a well-known branch name, which I can then promote to default branch, without using rename = true. If I auto-init, the default branch name needs to be queried, since it's known after apply. However, I cannot decide whether or not I use rename = true or even have to create the github_default_branch based on the github_repository output, because it's (known after apply).

What I want to do is safely create a Repository and set a default branch to main, so my other resources can safely rely on that, but this turns out to be tricky - or I'm missing something obvious, which is entirely possible.

Terraform Version

Terraform v1.11.4
on linux_amd64

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

Affected Resource(s)

  • github_branch_default

Terraform Configuration Files

resource "github_repository" "test" {
  name       = "test-repo"
  visibility = "private"
  auto_init  = true # Ensures that there is a branch
}

resource "github_branch_default" "default" {
  count      = var.set_default_branch ? 1 : 0
  repository = github_repository.test.name
  branch     = github_repository.test.default_branch
  rename     = true
}

variable "set_default_branch" {
  type     = bool
  default  = false
  nullable = false
}

provider "github" {}

terraform {
  required_version = ">= 1.11"
  required_providers {
    github = {
      source  = "integrations/github"
      version = "6.6.0"
    }
  }
}

Steps to Reproduce

  1. Run terraform apply, which will create only the Repository and initialize it (auto_init = true), ensuring there is a branch
  2. Run terraform apply -var set_default_branch=true to add github_branch_default to the configuration
  3. GitHub API will return the error 422 Validation Failed [{Resource: Field: Code: Message:New branch cannot be the same as the current branch}]

Note

I'm using the deprecated default_branch attribute here, but that's just for convenience. The error appears only for some users, if the configured branch for github_branch_name happens to match the already existing default Branch.
In my humble opinion, the better behavior for this Provider would be to check the current default branch and just "accept" the existing default Branch setting, if it already matches the configured one. This feels more intuitive and idempotent to me.

Debug Output

2025-10-27T23:05:17.245+0100 [INFO]  Terraform version: 1.11.4
2025-10-27T23:05:17.245+0100 [DEBUG] using github.com/hashicorp/go-tfe v1.70.0
2025-10-27T23:05:17.245+0100 [DEBUG] using github.com/hashicorp/hcl/v2 v2.23.0
2025-10-27T23:05:17.245+0100 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2025-10-27T23:05:17.245+0100 [DEBUG] using github.com/zclconf/go-cty v1.16.0
2025-10-27T23:05:17.245+0100 [INFO]  Go runtime version: go1.23.3
2025-10-27T23:05:17.245+0100 [INFO]  CLI args: []string{"terraform", "apply", "-var", "set_default_branch=true", "-auto-approve", "-no-color"}
2025-10-27T23:05:17.245+0100 [DEBUG] Attempting to open CLI config file: /home/USERNAME_REDACTED/.terraformrc
2025-10-27T23:05:17.245+0100 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2025-10-27T23:05:17.245+0100 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2025-10-27T23:05:17.245+0100 [DEBUG] ignoring non-existing provider search directory /home/USERNAME_REDACTED/.terraform.d/plugins
2025-10-27T23:05:17.245+0100 [DEBUG] ignoring non-existing provider search directory /home/USERNAME_REDACTED/.local/share/terraform/plugins
2025-10-27T23:05:17.245+0100 [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2025-10-27T23:05:17.245+0100 [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
2025-10-27T23:05:17.245+0100 [DEBUG] ignoring non-existing provider search directory /var/lib/snapd/desktop/terraform/plugins
2025-10-27T23:05:17.246+0100 [INFO]  CLI command args: []string{"apply", "-var", "set_default_branch=true", "-auto-approve", "-no-color"}
2025-10-27T23:05:17.263+0100 [DEBUG] checking for provisioner in "."
2025-10-27T23:05:17.269+0100 [DEBUG] checking for provisioner in "/usr/bin"
2025-10-27T23:05:17.270+0100 [INFO]  backend/local: starting Apply operation
2025-10-27T23:05:17.272+0100 [DEBUG] created provider logger: level=debug
2025-10-27T23:05:17.272+0100 [INFO]  provider: configuring client automatic mTLS
2025-10-27T23:05:17.285+0100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0 args=[".terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0"]
2025-10-27T23:05:17.286+0100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0 pid=8500
2025-10-27T23:05:17.286+0100 [DEBUG] provider: waiting for RPC address: plugin=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0
2025-10-27T23:05:17.294+0100 [INFO]  provider.terraform-provider-github_v6.6.0: configuring server automatic mTLS: timestamp="2025-10-27T23:05:17.294+0100"
2025-10-27T23:05:17.309+0100 [DEBUG] provider.terraform-provider-github_v6.6.0: plugin address: address=/tmp/plugin3193076804 network=unix timestamp="2025-10-27T23:05:17.309+0100"
2025-10-27T23:05:17.309+0100 [DEBUG] provider: using plugin: version=5
2025-10-27T23:05:17.344+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-10-27T23:05:17.347+0100 [INFO]  provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0 id=8500
2025-10-27T23:05:17.347+0100 [DEBUG] provider: plugin exited
2025-10-27T23:05:17.347+0100 [DEBUG] Building and walking validate graph
2025-10-27T23:05:17.348+0100 [DEBUG] ProviderTransformer: "github_repository.test" (*terraform.NodeValidatableResource) needs provider["registry.terraform.io/integrations/github"]
2025-10-27T23:05:17.348+0100 [DEBUG] ProviderTransformer: "github_branch_default.default" (*terraform.NodeValidatableResource) needs provider["registry.terraform.io/integrations/github"]
2025-10-27T23:05:17.348+0100 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/integrations/github\"]" references: []
2025-10-27T23:05:17.348+0100 [DEBUG] ReferenceTransformer: "github_repository.test" references: []
2025-10-27T23:05:17.348+0100 [DEBUG] ReferenceTransformer: "github_branch_default.default" references: [var.set_default_branch github_repository.test github_repository.test]
2025-10-27T23:05:17.348+0100 [DEBUG] ReferenceTransformer: "var.set_default_branch" references: []
2025-10-27T23:05:17.349+0100 [DEBUG] Starting graph walk: walkValidate
2025-10-27T23:05:17.350+0100 [DEBUG] created provider logger: level=debug
2025-10-27T23:05:17.350+0100 [INFO]  provider: configuring client automatic mTLS
2025-10-27T23:05:17.356+0100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0 args=[".terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0"]
2025-10-27T23:05:17.356+0100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0 pid=8513
2025-10-27T23:05:17.356+0100 [DEBUG] provider: waiting for RPC address: plugin=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0
2025-10-27T23:05:17.364+0100 [INFO]  provider.terraform-provider-github_v6.6.0: configuring server automatic mTLS: timestamp="2025-10-27T23:05:17.364+0100"
2025-10-27T23:05:17.380+0100 [DEBUG] provider: using plugin: version=5
2025-10-27T23:05:17.380+0100 [DEBUG] provider.terraform-provider-github_v6.6.0: plugin address: network=unix address=/tmp/plugin3876150369 timestamp="2025-10-27T23:05:17.380+0100"
2025-10-27T23:05:17.399+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-10-27T23:05:17.403+0100 [INFO]  provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0 id=8513
2025-10-27T23:05:17.403+0100 [DEBUG] provider: plugin exited
2025-10-27T23:05:17.404+0100 [INFO]  backend/local: apply calling Plan
2025-10-27T23:05:17.404+0100 [DEBUG] Building and walking plan graph for NormalMode
2025-10-27T23:05:17.404+0100 [DEBUG] ProviderTransformer: "github_repository.test (expand)" (*terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/integrations/github"]
2025-10-27T23:05:17.404+0100 [DEBUG] ProviderTransformer: "github_branch_default.default (expand)" (*terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/integrations/github"]
2025-10-27T23:05:17.405+0100 [DEBUG] ReferenceTransformer: "github_repository.test (expand)" references: []
2025-10-27T23:05:17.405+0100 [DEBUG] ReferenceTransformer: "github_branch_default.default (expand)" references: [var.set_default_branch github_repository.test (expand) github_repository.test (expand)]
2025-10-27T23:05:17.405+0100 [DEBUG] ReferenceTransformer: "var.set_default_branch" references: []
2025-10-27T23:05:17.405+0100 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/integrations/github\"]" references: []
2025-10-27T23:05:17.406+0100 [DEBUG] Starting graph walk: walkPlan
2025-10-27T23:05:17.407+0100 [DEBUG] created provider logger: level=debug
2025-10-27T23:05:17.407+0100 [INFO]  provider: configuring client automatic mTLS
2025-10-27T23:05:17.413+0100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0 args=[".terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0"]
2025-10-27T23:05:17.413+0100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0 pid=8525
2025-10-27T23:05:17.414+0100 [DEBUG] provider: waiting for RPC address: plugin=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0
2025-10-27T23:05:17.422+0100 [INFO]  provider.terraform-provider-github_v6.6.0: configuring server automatic mTLS: timestamp="2025-10-27T23:05:17.421+0100"
2025-10-27T23:05:17.438+0100 [DEBUG] provider: using plugin: version=5
2025-10-27T23:05:17.438+0100 [DEBUG] provider.terraform-provider-github_v6.6.0: plugin address: address=/tmp/plugin2881270086 network=unix timestamp="2025-10-27T23:05:17.437+0100"
2025-10-27T23:05:17.453+0100 [WARN]  ValidateProviderConfig from "provider[\"registry.terraform.io/integrations/github\"]" changed the config value, but that value is unused
2025-10-27T23:05:17.454+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:17 [INFO] Selecting owner  from GITHUB_OWNER environment variable: timestamp="2025-10-27T23:05:17.454+0100"
2025-10-27T23:05:17.761+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:17 [INFO] Using the token from GitHub CLI: timestamp="2025-10-27T23:05:17.761+0100"
2025-10-27T23:05:17.761+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:17 [INFO] Setting write_delay_ms to 1000: timestamp="2025-10-27T23:05:17.761+0100"
2025-10-27T23:05:17.761+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:17 [DEBUG] Setting read_delay_ms to 0: timestamp="2025-10-27T23:05:17.761+0100"
2025-10-27T23:05:17.761+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:17 [DEBUG] Setting retry_delay_ms to 0: timestamp="2025-10-27T23:05:17.761+0100"
2025-10-27T23:05:17.761+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:17 [DEBUG] Setting max_retries to 3: timestamp="2025-10-27T23:05:17.761+0100"
2025-10-27T23:05:17.761+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:17 [DEBUG] Setting retriableErrors to map[500:true 502:true 503:true 504:true]: timestamp="2025-10-27T23:05:17.761+0100"
2025-10-27T23:05:17.761+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:17 [DEBUG] Setting parallel_requests to false: timestamp="2025-10-27T23:05:17.761+0100"
2025-10-27T23:05:18.947+0100 [DEBUG] ReferenceTransformer: "github_repository.test" references: []
github_repository.test: Refreshing state... [id=test-repo]
2025-10-27T23:05:19.352+0100 [WARN]  Provider "registry.terraform.io/integrations/github" produced an invalid plan for github_repository.test, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .allow_update_branch: planned value cty.False for a non-computed attribute
      - .squash_merge_commit_title: planned value cty.StringVal("COMMIT_OR_PR_TITLE") for a non-computed attribute
      - .vulnerability_alerts: planned value cty.False for a non-computed attribute
      - .allow_rebase_merge: planned value cty.True for a non-computed attribute
      - .has_projects: planned value cty.False for a non-computed attribute
      - .merge_commit_title: planned value cty.StringVal("MERGE_MESSAGE") for a non-computed attribute
      - .merge_commit_message: planned value cty.StringVal("PR_TITLE") for a non-computed attribute
      - .web_commit_signoff_required: planned value cty.False for a non-computed attribute
      - .allow_auto_merge: planned value cty.False for a non-computed attribute
      - .homepage_url: planned value cty.StringVal("") for a non-computed attribute
      - .description: planned value cty.StringVal("") for a non-computed attribute
      - .has_issues: planned value cty.False for a non-computed attribute
      - .has_wiki: planned value cty.False for a non-computed attribute
      - .allow_squash_merge: planned value cty.True for a non-computed attribute
      - .has_discussions: planned value cty.False for a non-computed attribute
      - .is_template: planned value cty.False for a non-computed attribute
      - .archived: planned value cty.False for a non-computed attribute
      - .delete_branch_on_merge: planned value cty.False for a non-computed attribute
      - .squash_merge_commit_message: planned value cty.StringVal("COMMIT_MESSAGES") for a non-computed attribute
      - .allow_merge_commit: planned value cty.True for a non-computed attribute
      - .has_downloads: planned value cty.False for a non-computed attribute
2025-10-27T23:05:19.353+0100 [DEBUG] Resource instance state not found for node "github_branch_default.default[0]", instance github_branch_default.default[0]
2025-10-27T23:05:19.353+0100 [DEBUG] ReferenceTransformer: "github_branch_default.default[0]" references: []
2025-10-27T23:05:19.353+0100 [DEBUG] refresh: github_branch_default.default[0]: no state, so not refreshing
2025-10-27T23:05:19.357+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-10-27T23:05:19.362+0100 [INFO]  provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0 id=8525
2025-10-27T23:05:19.362+0100 [DEBUG] provider: plugin exited
2025-10-27T23:05:19.362+0100 [DEBUG] building apply graph to check for errors
2025-10-27T23:05:19.363+0100 [DEBUG] Resource state not found for node "github_branch_default.default[0]", instance github_branch_default.default[0]
2025-10-27T23:05:19.363+0100 [DEBUG] ProviderTransformer: "github_branch_default.default[0]" (*terraform.NodeApplyableResourceInstance) needs provider["registry.terraform.io/integrations/github"]
2025-10-27T23:05:19.363+0100 [DEBUG] ProviderTransformer: "github_repository.test (expand)" (*terraform.nodeExpandApplyableResource) needs provider["registry.terraform.io/integrations/github"]
2025-10-27T23:05:19.363+0100 [DEBUG] ProviderTransformer: "github_branch_default.default (expand)" (*terraform.nodeExpandApplyableResource) needs provider["registry.terraform.io/integrations/github"]
2025-10-27T23:05:19.363+0100 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/integrations/github\"]" references: []
2025-10-27T23:05:19.363+0100 [DEBUG] ReferenceTransformer: "github_repository.test (expand)" references: []
2025-10-27T23:05:19.363+0100 [DEBUG] ReferenceTransformer: "github_branch_default.default (expand)" references: [var.set_default_branch github_repository.test (expand) github_repository.test (expand)]
2025-10-27T23:05:19.363+0100 [DEBUG] ReferenceTransformer: "var.set_default_branch" references: []
2025-10-27T23:05:19.363+0100 [DEBUG] ReferenceTransformer: "github_branch_default.default[0]" references: [var.set_default_branch github_repository.test (expand) github_repository.test (expand)]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # github_branch_default.default[0] will be created
  + resource "github_branch_default" "default" {
      + branch     = "master"
      + etag       = (known after apply)
      + id         = (known after apply)
      + rename     = true
      + repository = "test-repo"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
2025-10-27T23:05:19.365+0100 [INFO]  backend/local: apply calling Apply
2025-10-27T23:05:19.365+0100 [DEBUG] Building and walking apply graph for NormalMode plan
2025-10-27T23:05:19.365+0100 [DEBUG] Resource state not found for node "github_branch_default.default[0]", instance github_branch_default.default[0]
2025-10-27T23:05:19.366+0100 [DEBUG] ProviderTransformer: "github_branch_default.default (expand)" (*terraform.nodeExpandApplyableResource) needs provider["registry.terraform.io/integrations/github"]
2025-10-27T23:05:19.366+0100 [DEBUG] ProviderTransformer: "github_branch_default.default[0]" (*terraform.NodeApplyableResourceInstance) needs provider["registry.terraform.io/integrations/github"]
2025-10-27T23:05:19.366+0100 [DEBUG] ProviderTransformer: "github_repository.test (expand)" (*terraform.nodeExpandApplyableResource) needs provider["registry.terraform.io/integrations/github"]
2025-10-27T23:05:19.366+0100 [DEBUG] ReferenceTransformer: "github_branch_default.default (expand)" references: [var.set_default_branch github_repository.test (expand) github_repository.test (expand)]
2025-10-27T23:05:19.366+0100 [DEBUG] ReferenceTransformer: "var.set_default_branch" references: []
2025-10-27T23:05:19.366+0100 [DEBUG] ReferenceTransformer: "github_branch_default.default[0]" references: [var.set_default_branch github_repository.test (expand) github_repository.test (expand)]
2025-10-27T23:05:19.366+0100 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/integrations/github\"]" references: []
2025-10-27T23:05:19.366+0100 [DEBUG] ReferenceTransformer: "github_repository.test (expand)" references: []
2025-10-27T23:05:19.367+0100 [DEBUG] Starting graph walk: walkApply
2025-10-27T23:05:19.367+0100 [DEBUG] created provider logger: level=debug
2025-10-27T23:05:19.367+0100 [INFO]  provider: configuring client automatic mTLS
2025-10-27T23:05:19.372+0100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0 args=[".terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0"]
2025-10-27T23:05:19.373+0100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0 pid=8559
2025-10-27T23:05:19.373+0100 [DEBUG] provider: waiting for RPC address: plugin=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0
2025-10-27T23:05:19.381+0100 [INFO]  provider.terraform-provider-github_v6.6.0: configuring server automatic mTLS: timestamp="2025-10-27T23:05:19.381+0100"
2025-10-27T23:05:19.396+0100 [DEBUG] provider: using plugin: version=5
2025-10-27T23:05:19.396+0100 [DEBUG] provider.terraform-provider-github_v6.6.0: plugin address: address=/tmp/plugin2800923234 network=unix timestamp="2025-10-27T23:05:19.396+0100"
2025-10-27T23:05:19.410+0100 [WARN]  ValidateProviderConfig from "provider[\"registry.terraform.io/integrations/github\"]" changed the config value, but that value is unused
2025-10-27T23:05:19.411+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:19 [INFO] Selecting owner  from GITHUB_OWNER environment variable: timestamp="2025-10-27T23:05:19.411+0100"
2025-10-27T23:05:19.715+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:19 [INFO] Using the token from GitHub CLI: timestamp="2025-10-27T23:05:19.715+0100"
2025-10-27T23:05:19.715+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:19 [INFO] Setting write_delay_ms to 1000: timestamp="2025-10-27T23:05:19.715+0100"
2025-10-27T23:05:19.715+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:19 [DEBUG] Setting read_delay_ms to 0: timestamp="2025-10-27T23:05:19.715+0100"
2025-10-27T23:05:19.715+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:19 [DEBUG] Setting retry_delay_ms to 0: timestamp="2025-10-27T23:05:19.715+0100"
2025-10-27T23:05:19.715+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:19 [DEBUG] Setting max_retries to 3: timestamp="2025-10-27T23:05:19.715+0100"
2025-10-27T23:05:19.715+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:19 [DEBUG] Setting retriableErrors to map[500:true 502:true 503:true 504:true]: timestamp="2025-10-27T23:05:19.715+0100"
2025-10-27T23:05:19.715+0100 [INFO]  provider.terraform-provider-github_v6.6.0: 2025/10/27 23:05:19 [DEBUG] Setting parallel_requests to false: timestamp="2025-10-27T23:05:19.715+0100"
github_branch_default.default[0]: Creating...
2025-10-27T23:05:20.886+0100 [INFO]  Starting apply for github_branch_default.default[0]
2025-10-27T23:05:20.887+0100 [DEBUG] github_branch_default.default[0]: applying the planned Create change
2025-10-27T23:05:21.373+0100 [ERROR] provider.terraform-provider-github_v6.6.0: Response contains error diagnostic: @module=sdk.proto diagnostic_detail="" tf_req_id=8b40e2e8-befa-ae12-4f4f-6f07a4ba216d tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:58 diagnostic_severity=ERROR diagnostic_summary="POST https://api.github.com/repos/V0idC0de/test-repo/branches/master/rename: 422 Validation Failed [{Resource: Field: Code: Message:New branch cannot be the same as the current branch}]" tf_proto_version=5.6 tf_provider_addr=provider tf_resource_type=github_branch_default timestamp="2025-10-27T23:05:21.373+0100"
2025-10-27T23:05:21.378+0100 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2025-10-27T23:05:21.378+0100 [ERROR] vertex "github_branch_default.default[0]" error: POST https://api.github.com/repos/V0idC0de/test-repo/branches/master/rename: 422 Validation Failed [{Resource: Field: Code: Message:New branch cannot be the same as the current branch}]

Warning: Deprecated attribute

  on main.tf line 10, in resource "github_branch_default" "default":
  10:   branch     = github_repository.test.default_branch

The attribute "default_branch" is deprecated. Refer to the provider
documentation for details.

(and 3 more similar warnings elsewhere)

Error: POST https://api.github.com/repos/V0idC0de/test-repo/branches/master/rename: 422 Validation Failed [{Resource: Field: Code: Message:New branch cannot be the same as the current branch}]

  with github_branch_default.default[0],
  on main.tf line 7, in resource "github_branch_default" "default":
   7: resource "github_branch_default" "default" {

2025-10-27T23:05:21.384+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-10-27T23:05:21.388+0100 [INFO]  provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/integrations/github/6.6.0/linux_amd64/terraform-provider-github_v6.6.0 id=8559
2025-10-27T23:05:21.388+0100 [DEBUG] provider: plugin exited

Panic Output

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageThis is being looked at and prioritizedType: BugSomething isn't working as documented

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions