Repository navigation
Error processing 422 response codes #9
Description
Activity
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.
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.
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"})
@zampettim Thank you! I misunderstood doc.
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.