Skip to content

Incorrect error-parsing on failure of creating review #1136

Description

@wataash

Original error info from GitHub API (formatted for readability):

$ curl -H "Authorization: token XXXXXXXX" -X POST -d '{"commit_id": "ffffffffff"}' https://api.github.com/repos/wataash/sandbox/pulls/1/reviews
{
  "message": "Unprocessable Entity",
  "errors": [
    "Variable commitOID of type GitObjectID was provided invalid value"
  ],
  "documentation_url": "https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review"
}

indicates the commit id ffffffffff doesn't exist.

Same one via go-github:

ctx := context.Background()
ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: "XXXXXXXX"})
tc := oauth2.NewClient(ctx, ts)
client := github.NewClient(tc)
nonExistCommitID := "ffffffffff"
review := github.PullRequestReviewRequest{CommitID: &nonExistCommitID}
_, _, err := client.PullRequests.CreateReview(ctx, "wataash", "sandbox", 1, &review)
_, _ = fmt.Printf("%+v\n", err)

prints:

POST https://api.github.com/repos/wataash/sandbox/pulls/1/reviews: 422 Unprocessable Entity [{Resource: Field: Code: Message:}]

which lacks the error details but shows unrelated fields.

Activity

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