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

rover-client does not check for a successful response before parsing the body #394

Closed
lrlna opened this issue Mar 30, 2021 · 0 comments · Fixed by #395
Closed

rover-client does not check for a successful response before parsing the body #394

lrlna opened this issue Mar 30, 2021 · 0 comments · Fixed by #395
Labels

Comments

@lrlna
Copy link
Member

lrlna commented Mar 30, 2021

Description

When trying to introspect an endpoint that I (rightfully so) am not allowed to introspect, I receive a could not parse JSON error even though the response was actually a 405 Not Allowed.

This happens because we are trying to parse a response body that is not a json. Since it's unlikely that an unsuccessful request will ever have a body that is json, we should account for different types of responses. We should also account for the fact that we might have an unsuccessful request.

Steps to reproduce

rover graph introspect https://codesandbox.io/s/ecstatic-wu-orekg --log=debug will get you the same response.

Expected result

We should return a 405 Not Allowed error.

Actual result

   DEBUGrover_client::blocking::client: <html>
<head><title>405 Not Allowed</title></head>
<body>
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx/1.16.1</center>
</body>
</html>

    at crates/rover-client/src/blocking/client.rs:53

   DEBUGrover: error: RoverError { error: could not parse JSON

Caused by:
    expected value at line 1 column 1, metadata: Metadata { suggestion: Some(SubmitIssue), code: None, is_parse_error: false } }
    at src/bin/rover.rs:18

error: could not parse JSON
        This error was unexpected! Please submit an issue with any relevant details about what you were trying to do: https://github.com/apollographql/rover/issues/new

Environment

Rover Info:
Version: 0.0.4
Install Location: /Users/lrlna/developer/apollographql/rover/target/debug/rover
OS: Mac OS 10.14.5 [64-bit]
Shell: /bin/zsh

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

Successfully merging a pull request may close this issue.

1 participant