Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#3,552 5 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
go, terraform
Lĩnh vực
devops, infrastructure

Hướng nghiên cứu

Bắt đầu với các triển khai tài nguyên github_branch và github_branch_protection, đồng thời tái hiện cấu hình Terraform được cung cấp trong khi theo dõi ID toàn cục của quy tắc bảo vệ sau khi đổi tên branch. Hoàn thành khi việc đổi tên một branch được bảo vệ được áp dụng thành công mà không gặp lỗi global-ID và cơ chế bảo vệ hiện có vẫn chính xác.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Go
Star
1.2k
Fork
1.1k
Merge trung bình
9 giờ 41 phút
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của integrations/terraform-provider-github

Tất cả issue của integrations/terraform-provider-github

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.