Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating review with wrong commit ID crashed exception thrower #848

Open
olivernybroe opened this issue Feb 11, 2020 · 2 comments
Open

Creating review with wrong commit ID crashed exception thrower #848

olivernybroe opened this issue Feb 11, 2020 · 2 comments

Comments

@olivernybroe
Copy link

@olivernybroe olivernybroe commented Feb 11, 2020

When creating a review which has a commit ID which is not part of the PR, the exception thrower crashes, as there are no code field in the errors array from GitHub.

This is the data from GitHub

array:3 [
  "message" => "Unprocessable Entity"
  "errors" => array:1 [
    0 => "End commit oid is not part of the pull request"
  ]
  "documentation_url" => "https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review"
]
@acrobat

This comment has been minimized.

Copy link
Collaborator

@acrobat acrobat commented Feb 13, 2020

@olivernybroe what do you mean with “crashes”? And what is the http code github returns for this call?

@olivernybroe

This comment has been minimized.

Copy link
Author

@olivernybroe olivernybroe commented Feb 14, 2020

I gives a 422 back.

It fails on this line

if (422 === $response->getStatusCode() && isset($content['errors'])) {
$errors = [];
foreach ($content['errors'] as $error) {
switch ($error['code']) {
case 'missing':
$errors[] = sprintf('The %s %s does not exist, for resource "%s"', $error['field'], $error['value'], $error['resource']);

because errors array does not have a code property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.