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

Parse 502 status code response as a GraphQL response. #38

Open
dmitshur opened this issue Oct 24, 2018 · 2 comments
Open

Parse 502 status code response as a GraphQL response. #38

dmitshur opened this issue Oct 24, 2018 · 2 comments
Labels
enhancement NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@dmitshur
Copy link
Member

dmitshur commented Oct 24, 2018

As reported by @cjwagner in shurcooL/graphql#29 (comment) and recently reproduced by me, GitHub GraphQL API v4 can return a response with status code 502 that includes a valid GraphQL response:

{
    "data":"null",
    "errors":[
        {
            "message":"Something went wrong while executing your query. This may be the result of a timeout, or it could be a GitHub bug. Please include `8FF2:721B:31D84D5:6EF58BD:5BCF3079` when reporting this issue."
        }
    ]
}

(I'm a little surprised and concerned that data field is a string "null" rather than a JSON null value. It's still valid JSON, but... According to GraphQL spec, "If an error was encountered during the execution that prevented a valid response, the data entry in the response should be null.")

We can parse it as such, instead of returning a generic "non-200 OK status code" error:

image

This may depend on shurcooL/graphql#5 being resolved, or maybe there's a shorter path to getting this done.

@dmitshur dmitshur added enhancement NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Oct 24, 2018
@dmitshur
Copy link
Member Author

Another use case is for detecting when a rate limit is hit. According to #57 (comment), GitHub returns HTTP 429 status code in those cases.

@MichaelMure
Copy link

According to #57 (comment), GitHub returns HTTP 429 status code in those cases.

I actually don't know, it's just what I expected to happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Development

No branches or pull requests

2 participants