You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] Add checks field to RequiredStatusChecks #2274
I did some more research, with some CURLs and realized that in required_status_checks you must supply either contexts or checks, but you cannot supply both at the same time:
curl -X PUT -H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token REDACTED" \
https://api.github.com/repos/ORG/REPO_NAME/branches/BRANCH_NAME/protection \
-d '{"enforce_admins": null, "required_pull_request_reviews": null,
"required_status_checks":{"strict":true,"contexts":["contexts"],"checks":[{"context":"contexts"}]},
"restrictions": null}'
{
"message": "Invalid request.\n\nNo subschema in \"anyOf\" matched.\nMore than one subschema in \"oneOf\" matched.\nNot all subschemas of \"allOf\" matched.\nFor 'anyOf/1', {\"strict\"=>true, \"contexts\"=>[\"contexts\"], \"checks\"=>[{\"context\"=>\"contexts\"}]} is not a null.",
"documentation_url": "https://docs.github.com/rest/reference/repos#update-branch-protection"
}
Right now, I'm kind of stuck on figuring out how to enforce this logic/rule in go-github to help prevent these invalid request errors. Is there an example of how to specify a required one or the other field logic?
If both fields are slices with omitempty, then you could set one or the other to nil and they should not be passed to the endpoint (which you can confirm with a unit test).
Activity
gmlewis commentedon Jan 27, 2022
Thank you, @k24dizzle ! Would you like to make a PR, or shall I open this up to other contributors to this repo?
k24dizzle commentedon Jan 27, 2022
Hi @gmlewis, new to contributing to this repo but I can give it a shot
gmlewis commentedon Jan 27, 2022
Excellent, @k24dizzle !
Please make sure to check out our CONTRIBUTING.md file for how to get started.
k24dizzle commentedon Jan 27, 2022
I did some more research, with some CURLs and realized that in
required_status_checksyou must supply eithercontextsorchecks, but you cannot supply both at the same time:So the documentation given by github is a little misleading:
You could just provide
checks(withoutcontexts) for example and this should work:Right now, I'm kind of stuck on figuring out how to enforce this logic/rule in
go-githubto help prevent theseinvalid requesterrors. Is there an example of how to specify arequired one or the other fieldlogic?gmlewis commentedon Jan 27, 2022
If both fields are slices with
omitempty, then you could set one or the other toniland they should not be passed to the endpoint (which you can confirm with a unit test).Add checks field to RequiredStatusChecks (google#2276)
Add checks field to RequiredStatusChecks (google#2276)