-
Notifications
You must be signed in to change notification settings - Fork 949
Cannot create github_branch_protection_v3 after update to v5.3.0 #1307
Copy link
Copy link
Closed
Labels
Status: Up for grabsIssues that are ready to be worked on by anyoneIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documentedSomething isn't working as documented
Description
Terraform Version
v5.3.0
Affected Resource(s)
- github_branch_protection_v3
- github_branch_default
- github_branch_default
The issue occures when creating a new github_branch_protection_v3 resource with attributes referenced from github_branch_default and github_branch_protection_v3 resources.
Debug Output
github_branch_protection_v3.<MY_REPO_NAME_REDACTED>: Creating...
╷
│ Error: PUT https://api.github.com/repos/<MY_ORG_REDACTED>/<MY_REPO_NAME_REDACTED>/branches/main/protection: 422 Invalid request.
│
│ No subschema in "anyOf" matched.
│ For 'properties/checks', nil is not an array.
│ Not all subschemas of "allOf" matched.
│ For 'anyOf/1', {"strict"=>true, "contexts"=>["build"], "checks"=>nil} is not a null. []
Expected Behavior
The branch protection v3 resource should be created.
Actual Behavior
Terraform errors out with message above.
Steps to Reproduce
Step 1
Create a repo with terraform apply.
resource "github_repository" "test-repo" {
name = "test-repo"
description = "This repo is a test"
has_downloads = true
has_issues = false
has_projects = false
has_wiki = false
visibility = "private"
auto_init = true
vulnerability_alerts = false
}
resource "github_branch_default" "test-repo" {
repository = github_repository.test-repo.name
branch = "main"
}
Step 2
Terraform apply the following change:
resource "github_branch_protection_v3" "test-repo" {
repository = github_repository.test-repo.name
branch = github_branch_default.test-repo.branch
enforce_admins = true
required_status_checks {
strict = true
contexts = ["build"]
}
required_pull_request_reviews {
dismiss_stale_reviews = true
require_code_owner_reviews = true
}
}
Important Factoids
This works up to GitHub provider version v5.2.0 without errors and errors in v5.3.0.
This seems to be linked to the go client update in the release diff where the API Client is updated as follows.
terraform-provider-github/vendor/github.com/google/go-github/v47/github/repos.go
Line 908 in 6773d80
| Checks []*RequiredStatusCheck `json:"checks"` |
From
Checks []*RequiredStatusCheck `json:"checks,omitempty"
To
Checks []*RequiredStatusCheck `json:"checks"`
References
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Status: Up for grabsIssues that are ready to be worked on by anyoneIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documentedSomething isn't working as documented
Type
Projects
Status
✅ Done