-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Error when creating branch protection #2467
Comments
Looking at https://github.com/orgs/community/discussions/24642 removing |
I've tested this locally, removing github.ProtectionRequest{
EnforceAdmins: r.EnforceAdmins,
RequiredPullRequestReviews: &github.PullRequestReviewsEnforcementRequest{
DismissStaleReviews: r.DismissStaleReviews,
RequiredApprovingReviewCount: r.RequiredApprovingReviewCount,
RequireCodeOwnerReviews: r.RequireCodeOwnerReviews,
},
RequiredStatusChecks: &github.RequiredStatusChecks{
Strict: true,
Checks: []*github.RequiredStatusCheck{},
},
} Works, and you might not need to fully deprecate I've opened #2468 to remove the |
Thank you very much for the quick turnaround on this @gmlewis 🚀 |
Yes, I can work on a new release today. |
Awesome, thanks. Really appreciate it 👍 |
@luisdavim - this issue has now been covered in the latest release: |
When attempting to update I ran into the same issue as integrations/terraform-provider-github#1307. It appears that golang is setting the value to
|
@luisdavim - do you have any insights to this new issue? @alock - just for the record, this repo is now sending an empty |
I think the terraform provider still needs to be updated to use a version of this lib that contains the fix.... |
Ah, thank you, @luisdavim ! Then I'll close this issue to hopefully reduce the confusion... but please report back if you feel we introduced a regression. |
It looks like the Terraform provider updated to go-github v48.1.0 17 days ago, and published those changes in their v5.11.0 release However I still receive the same issue attempting to apply: ╷
│ Error: PUT https://api.github.com/repos/<org>/status/branches/<b>/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"=>false, "checks"=>nil} is not a null. []
│
│ with module.repository["<service>"].github_branch_protection_v3.branch_protection[1],
│ on .terraform/modules/repository/main.tf line 240, in resource "github_branch_protection_v3" "branch_protection":
│ 240: resource "github_branch_protection_v3" "branch_protection" {
│
╵
╷
│ Error: PUT https://api.github.com/repos/<org>/status/branches/<a>/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"=>false, "contexts"=>["go / Build"], "checks"=>nil} is not a null. []
│
│ with module.repository["<service>"].github_branch_protection_v3.branch_protection[0],
│ on .terraform/modules/repository/main.tf line 240, in resource "github_branch_protection_v3" "branch_protection":
│ 240: resource "github_branch_protection_v3" "branch_protection" {
│
╵
Versions as such, is there something I'm missing here?
Any help appreciated 🙏 |
Reopening but need assistance on this one from Terraform users. |
The fix will have to be on the terraform provider side, to pass an empty array instead of nothing, the alternative could be to add logic to this library to set an empty array when it's |
Oh I see, per your comment above. Apologies for missing that. I'll open a PR downstream to try adding an empty array to the request in their utility file 👍 The idea to handle the nil gracefully upstream is a nice one, though you'd know best if there might be any interesting ramifications of that. Thanks for the response! |
Do keep on mind that if |
Duly noted. The Terraform provider has not yet been switched over to use It seems there is a downstream issue to track this upgrade: In the meantime I'll see about merging the PR to include an empty Checks array to resolve the immediate issue, though it might require a little more through than I initially realised. I'm happy to close this issue knowing that there is a downstream ticket to track deprecating I'll leave that decision to you 👍 |
OK, then I think we are good to go and I'll close this issue (again). |
I'm trying to run v57.0.0 of this, and I'm still getting this issue:
This is what our branch protection looks like:
|
Reopening. |
fyi: I'm getting the same issue. I tried to work around it but couldn't find a way. |
Thank you! :) |
I would recommend using the version that works for you for your particular use case, since we appear to have different use cases apparently. This difference in use cases will be part of what needs to be determined with a deep dive into fixing this issue. |
Please check out this comment: #2976 (comment) |
@KatharinaSick I've come with two potential workarounds that could work for your situation. If neither of them work, maybe I can try to help you find a solution. The workarounds are written here: #2976 (comment) |
Fixed by: #3070. |
Since we updated our code to use the latest version of this library, we can't create a branch protection that requires branches to be up to date before merging but don't require any status checks:
The above results in an error:
Such rule is possible to be created from the UI:
This is also affecting the Github Terraform provider: integrations/terraform-provider-github#1147
The text was updated successfully, but these errors were encountered: