-
Notifications
You must be signed in to change notification settings - Fork 715
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
fix: report http error if /api call fails #3702
Conversation
Previously it would try to run the JSON decoder on a string like "404 not found" and report that failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (except the small nit I commented on) ✔️
Fixes #3249
I think this relies on the assumption that /api
call failing is sole reason of JSON decoding failing - is there a chance /api
would ever successfully return a badly formatted JSON?
I just want to make sure the message in #3249 will be completely eliminated before we close it :)
@@ -192,6 +192,9 @@ func (c *appClient) Details() (xfer.Details, error) { | |||
if err != nil { | |||
return result, err | |||
} | |||
if resp.StatusCode != http.StatusOK { | |||
return result, fmt.Errorf("Error response from %s: %s", c.url("/api"), resp.Status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: based on your own log output (Error response from http://172.16.0.3:4040//api: 404 Not Found
), maybe there's an extra /
here:
return result, fmt.Errorf("Error response from %s: %s", c.url("/api"), resp.Status) | |
return result, fmt.Errorf("Error response from %s: %s", c.url("api"), resp.Status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output is correct: the reason it's failing is the url has too many slashes in it.
#3249 has (like many of our issues) multiple people reporting multiple sets of symptoms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Previously it would try to run the JSON decoder on a string like "404 not found" and report that failing with the message "Error fetching app details: only encoded map or array can be decoded into a struct".
Now it will report the http error, like this:
Fixes #3249