-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
Describe the bug
From within a GitHub Actions workflow, I want to delete review requests using gh api, but I get both an HTTP 422 response and an error message.
I'm using the gh version provided in the Ubuntu 18.04 GitHub-hosted runners, version 0.11.0 currently.
Steps to reproduce the behavior
I use
gh api "repos/:owner/:repo/pulls/$prid/requested_reviewers" \
--method DELETE --input - --silent --include < reviewers.jsonwhere $prid is the pull request ID and reviewers.json looks something like
{
"reviewers": [
"user1",
"user2"
]
}The returned headers show that this fails with
HTTP/1.1 422 Unprocessable Entity
and I get an error
json: cannot unmarshal string into Go struct field .Errors of type struct { Message string }
By now, I understand that the reason for the 422 is a permission issue; using curl for the same request results in the more descriptive error
{
"message": "Validation Failed",
"errors": [
"Could not resolve to a node with the global id of '<redacted>'."
],
"documentation_url": "https://developer.github.com/v3/pulls/review_requests/#delete-a-review-request"
}and using a personal access token instead of GITHUB_TOKEN works. (I wonder why that's required, though, and asked about it here.)
Expected vs actual behavior
I'd probably expect the client to handle the error case more gracefully than bubbling up the json unmarshalling error, and showing the actual error message would be helpful, too.
Logs
The complete output from --include and the response itself:
HTTP/1.1 422 Unprocessable Entity
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
Content-Length: 219
Content-Security-Policy: default-src 'none'
Content-Type: application/json; charset=utf-8
Date: Fri, 31 Jul 2020 20:06:01 GMT
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Server: GitHub.com
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
Vary: Accept-Encoding, Accept, X-Requested-With
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-Github-Media-Type: github.v3; format=json
X-Github-Request-Id: 0404:348C:1AF3B6:2E4595:5F2479A9
X-Ratelimit-Limit: 15000
X-Ratelimit-Remaining: 14981
X-Ratelimit-Reset: 1596228532
X-Xss-Protection: 1; mode=block
json: cannot unmarshal string into Go struct field .Errors of type struct { Message string }