Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[BUG]: changing branch name with protection rules set fails

Abierto
#3,552 5 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
go, terraform

Línea de trabajo

Comienza con las implementaciones de los recursos github_branch y github_branch_protection y reproduce la configuración de Terraform proporcionada, rastreando al mismo tiempo el ID global de la regla de protección después de renombrar una rama. Se considera terminado cuando renombrar una rama protegida se aplica correctamente sin el error de global-ID y la protección existente sigue siendo correcta.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Awaiting response Status: Needs info Status: Triage Type: Bug
Expected Behavior

on changing branch name that has protection rules set by terraform, its expected for the apply to work normally

Actual Behavior

branch name changes, however, protection rule modification fail with error : Could not resolve to a node with the global id of xxxxxxx

Terraform Version

Terraform v1.15.7
on linux_amd64

  • provider registry.terraform.io/hashicorp/github v6.13.0
GitHub Installation Type
  • GitHub.com (Free, Pro, or Team)
  • GitHub Enterprise Server (on-premises)
  • GitHub Enterprise Cloud with Personal Accounts (github.com)
  • GitHub Enterprise Cloud with Managed Users/EMU (github.com)
  • GitHub Enterprise Cloud with Data Residency (*.ghe.com)
  • I don't know
Affected Resource(s)
  • github_branch_protection
  • github_branch
Terraform Configuration Files
resource "github_repository" "terraform_lab" {
  name        = "tf-lab-practice"
  description = "Can I change this?"

  visibility         = "public"
  auto_init          = true
  allow_merge_commit = true
  allow_squash_merge = true
  topics             = ["terraform", "iac"]

}

resource "github_branch" "terraform_lab" {
  repository = github_repository.terraform_lab.name
  branch     = "master3"
}


resource "github_branch" "terraform_lab_dev" {
  repository = github_repository.terraform_lab.name
  branch     = "dev3"
}
resource "github_branch_default" "terraform_lab" {
  repository = github_repository.terraform_lab.name
  branch     = github_branch.terraform_lab.branch
}


resource "github_branch_protection" "terraform_lab" {
  repository_id = github_repository.terraform_lab.name

  pattern          = github_branch_default.terraform_lab.branch
  enforce_admins   = true
  allows_deletions = true

  required_pull_request_reviews {
    require_code_owner_reviews      = true
    dismiss_stale_reviews           = true
    restrict_dismissals             = true
    required_approving_review_count = 1
  }
}

resource "github_branch_protection" "terraform_lab_dev" {
  repository_id = github_repository.terraform_lab.name

  pattern          = github_branch.terraform_lab_dev.branch
  enforce_admins   = true
  allows_deletions = true

  required_pull_request_reviews {
    require_code_owner_reviews      = true
    dismiss_stale_reviews           = true
    restrict_dismissals             = true
    required_approving_review_count = 1
  }
}

output "repo_data" {
  value = github_repository.terraform_lab
}
output "default_branch_data" {
  value = github_branch_default.terraform_lab
}

terraform {
  required_version = ">= 1.12.2" # Replace with your installed version
  required_providers {
    github = {
      source  = "hashicorp/github"
      version = "~> 6.13"
    }

  }
}

provider "github" {}
Steps to Reproduce
export GITHUB_TOKEN
terraform apply #the code provided
#change any branch name
terraform apply
Debug Output
github_branch.terraform_lab_dev: Modifying... [id=tf-lab-practice:dev2]
github_branch_protection.terraform_lab: Modifying... [id=BPR_kwDOTcwWwc4Ey13a]
github_branch.terraform_lab_dev: Modifications complete after 4s [id=tf-lab-practice:dev3]
github_branch_protection.terraform_lab_dev: Modifying... [id=BPR_kwDOTcwWwc4Ey13b]
github_branch_protection.terraform_lab: Modifications complete after 8s [id=BPR_kwDOTcwWwc4Ey13a]
╷
│ Error: Could not resolve to a node with the global id of 'BPR_kwDOTcwWwc4Ey13b'.
│ 
│   with github_branch_protection.terraform_lab_dev,
│   on main.tf line 44, in resource "github_branch_protection" "terraform_lab_dev":
│   44: resource "github_branch_protection" "terraform_lab_dev" {
│ 
╵
Code of Conduct
  • I agree to follow this project's Code of Conduct
Lenguaje dominante
Go
Estrellas
1.2k
Forks
1.1k
Merge medio
9 h 41 min
PR fusionados (30 d)
3

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de integrations/terraform-provider-github

Todos los issues de integrations/terraform-provider-github

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.