Skip to content

PullRequestReviewsEnforcementRequest.DismissalRestrictionsRequest set to nil results in 422 from GH #664

Closed

Description

@mslusarczyk

According to doc user is able to pass nil to disable DismissalRestrictions and looking at method below this nil is converted to empty array.

Seems that this is not working properly because

&github.ProtectionRequest{
		RequiredPullRequestReviews: &github.PullRequestReviewsEnforcementRequest{DismissalRestrictionsRequest: nil, DismissStaleReviews:false},
	}

results in:

No subschema in "anyOf" matched.
For 'properties/dismissal_restrictions', [] is not an object.
Not all subschemas of "allOf" matched.
For 'anyOf/1', {"dismissal_restrictions"=>[], "dismiss_stale_reviews"=>false} is not a null. []]

and '422 Invalid request' from GH

@navarrano could you please take a look?

Activity

  1. iwata commented on Jul 21, 2017

    @iwata

    And I hope that PullRequestReviewsEnforcementRequest supports require_code_owner_reviews key 😄 .
    https://developer.github.com/v3/repos/branches/#update-branch-protection

  2. dmitshur commented on Jul 21, 2017

    @dmitshur
    Member

    I ran into this issue as well in #674. See

    // TODO: This test fails with 422 Validation Failed [{Resource: Field: Code: Message:}].
    // Someone familiar with protection requests needs to come up with
    // a valid protection request that doesn't give 422 error.
    .

    When this issue is resolved, that integration test can be fixed too.

  3. added 2 commits that reference this issue on Aug 10, 2017
    65110ef
    a7e43f5
  4. added a commit that references this issue on Aug 20, 2017
    c27cbe2
  5. beiriannydd commented on Aug 21, 2017

    @beiriannydd

    I have PR #703 in to fix this. It seems to be failing because I added a new library go-spew which is essentially the recursive %+v I always wanted and that doesn't get pulled in during the build.

  6. beiriannydd commented on Aug 21, 2017

    @beiriannydd

    Tests are passing :)

  7. dmitshur commented on Aug 22, 2017

    @dmitshur
    Member

    See my comment at #703 (comment).

    I think in order to resolve this bug, we need to figure out how to reproduce a successful response from GitHub using REST API. Then, once we have that, we can work on the Go code to fix the code, if needed.

  8. added a commit that references this issue on Aug 27, 2017
    6d6e485
  9. dmitshur commented on Sep 5, 2017

    @dmitshur
    Member

    From my understanding of #703, the way to get a successful response from GitHub is to perform the API call involving DismissalRestrictionsRequest on an organization-owned repository. It doesn't work on personal repositories and gives 422 in that case. /cc @beiriannydd

  10. JaredReisinger commented on Oct 30, 2017

    @JaredReisinger

    I just started seeing a 422 when an empty array is passed for dismissal_restrictions. The docs (https://developer.github.com/v3/repos/branches/#update-branch-protection) specifically mention that passing an empty array is the right way to disable dismissal restrictions (which is weird, IMO, since null would work just fine for this, and the object isn't normally an array)... so the current implementation is as per the docs, but GitHub still seems to be complaining.

    In any case, I have a support request out to GitHub to try to find out what the expected behavior is/should be. If the docs are wrong, and the property should be null (instead of an empty array), I'll provide a PR to make the change.

    Update: I just tried passing null—by modifying the JSON Marshal code—and GitHub complains about that too... the actual problem might be on GitHub's end. (I'm attempting to modify a private organization repo, not a personal or public repo.)

  11. dmitshur commented on Mar 19, 2018

    @dmitshur
    Member

    It seems to me that GitHub has updated the docs by now, and I'm not aware of what exactly we're waiting on them for, so removed that label. I think PR #791 will resolve this issue (let me know if not).

  12. added a commit that references this issue on Mar 28, 2018
    1ce85f4
  13. added a commit that references this issue on May 1, 2018
    fb40d24
  14. added a commit that references this issue on Jun 28, 2026
    526790e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions