-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
With the release of v32.0.0
, a BranchRestrictionsRequest
object now omits empty fields in the JSON, however, when passing a ProtectionRequest
with the following BranchRestrictionsRequest
object to the repositories.UpdateBranchProtection
method, the client returns the error below:
restrictions := new(github.BranchRestrictionsRequest)
restrictions.Users := []string{"angie44"}
restrictions.Teams := []string{}
restrictions.Apps := []string{}
Error: PUT https://api.github.com/repos/example-org/example-repo/branches/master/protection: 422 Invalid request.
No subschema in "anyOf" matched.
"teams" wasn't supplied.
Not all subschemas of "allOf" matched.
For 'anyOf/1', {"users"=>["anGie44"]} is not a null. []
Per the docs, empty fields in the BranchRestrictionsRequest
object should be specified with the empty []string{}
instead of nil
, but even so this results in the above error.
If however, the empty fields are set with a slice of size 1, i.e. make([]string, 1)
, then the PUT
request succeeds without error.
I wonder if there is another way we should be specifying the empty fields now that they are represented differently in the JSON request objects?
Metadata
Metadata
Assignees
Labels
No labels