Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Cannot add more than one team to Github_branch_protection_v3 bypass_pull_request_allowances #2033

Open
1 task done
andrewhharmon opened this issue Nov 29, 2023 · 2 comments · May be fixed by #2355
Open
1 task done
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@andrewhharmon
Copy link

Expected Behavior

when providing more than one value in the list for

bypass_pull_request_allowances {
    teams = ["teamA", "teamB"]
}

all teams in the list should be added

Actual Behavior

422 Validation Failed [{Resource: Field: Code: Message:Context must be unique per branch protection.}]

Terraform Version

Terraform Version 1.5.6
Provider version v5.42.0

Affected Resource(s)

Github_branch_protection_v3

Terraform Configuration Files

locals {
  # Create a map of repository names to repository data.
  repository_override = {
    repo-a = {
      teams = ["web-developers", "infrastructure-engineers"]
    }
}


resource "github_branch_protection_v3" "repos" {
  for_each = { for k, v in data.github_repository.repos : k => v }

  repository = each.value.name
  branch     = each.value.default_branch

  enforce_admins = false

  required_pull_request_reviews {
    required_approving_review_count = 1
    dismiss_stale_reviews           = true

    bypass_pull_request_allowances {
      teams = lookup(lookup(local.repository_override, each.value.name, {}), "teams", null)
      users = lookup(lookup(local.repository_override, each.value.name, {}), "users", null)
    }
  }

Steps to Reproduce

terraform apply

Debug Output

No response

Panic Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@andrewhharmon andrewhharmon added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Nov 29, 2023
Copy link

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@nickfloyd nickfloyd added Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels Jan 3, 2024
@kfcampbell
Copy link
Member

Oh that's interesting...the code is in place to flatten the provided list for the API call. I wonder if the fix is as simple as removing the MaxItems: 1, line in github/resource_github_branch_protection_v3.go and testing it with both a single item and a list.

Good catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
None yet
3 participants