Skip to content

Error processing 422 response codes #9

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

Closed
mzampetti0264 opened this issue Mar 16, 2015 · 4 comments
Closed

Error processing 422 response codes #9

mzampetti0264 opened this issue Mar 16, 2015 · 4 comments
Labels

Comments

@mzampetti0264
Copy link

When processing a request for Org members with 2fa using an account that is not part of the Owner team, the GH API returns a 422 response. The Api.php file tries to process the $content->errors property, but that doesn't exist in the response. So the response is missing the details of the error, and instead sees a stdClass::errors undefined property message.

@milo milo added the bug label Mar 16, 2015
@milo
Copy link
Owner

milo commented Mar 16, 2015

The 422 respose decoding is done here in Api, it is done according to documentation and it is covered by test.

Could you point me to GitHub API documentation which endpoint do you call? Or send me the error response dump.

@zampettim
Copy link

I don't think its an issue with the Github API directly, but a use case where the $content->errors object is not returned in the response from Github. In this case, the re-production is to make a call to /orgs/:org/members?filter=2fa_disabled using an Access Token that is NOT part of the Owner team. That will produce the 422 response, which does not contain an "errors" element. Just a "message" with the text about not being authorized.

I've submitted a Pull Request that has code to check to see if the $content->errors object exists before trying to use it to construct the message. Otherwise, it just uses the $content->message as the input to construct the exception.

@zampettim
Copy link

Here is the full trace of the response as well. Looking at the documentation, this seems to fall into the "custom" case, with the documenation_url link.


Github Request:
Milo\Github\Http\Response Object
(
[code:Milo\Github\Http\Response:private] => 422
[previous:Milo\Github\Http\Response:private] =>
[headers:Milo\Github\Http\Message:private] => Array
(
[server] => GitHub.com
[date] => Mon, 16 Mar 2015 20:12:48 GMT
[content-type] => application/json; charset=utf-8
[content-length] => 149
[status] => 422 Unprocessable Entity
[x-ratelimit-limit] => 5000
[x-ratelimit-remaining] => 4996
[x-ratelimit-reset] => 1426540257
[x-oauth-scopes] => admin:org, user
[x-accepted-oauth-scopes] => admin:org, read:org, repo, user, write:org
[x-github-media-type] => github.v3; format=json
[x-xss-protection] => 1; mode=block
[x-frame-options] => deny
[content-security-policy] => default-src 'none'
[access-control-allow-credentials] => true
[access-control-expose-headers] => ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
[access-control-allow-origin] => *
[x-github-request-id] => D1FBC8F5:51F4:82C203D:55073940
[strict-transport-security] => max-age=31536000; includeSubdomains; preload
[x-content-type-options] => nosniff
)

[content:Milo\Github\Http\Message:private] => {"message":"Only organization owners can use this filter.","documentation_url":"https://developer.github.com/v3/orgs/members/#audit-two-factor-auth"}

)

@milo milo closed this as completed in beea88a Mar 16, 2015
@milo
Copy link
Owner

milo commented Mar 16, 2015

@zampettim Thank you! I misunderstood doc.

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

No branches or pull requests

3 participants