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

Show more friendly error message with non JSON responses #151

Conversation

edwardkenfox
Copy link
Contributor

@edwardkenfox edwardkenfox commented Apr 15, 2018

I recently encountered a situation where Datadog API server responded to a JSON API request with status code 500, which is perfectly fine, but the problem was that even though the request was sent as Content-Type: application/json the response from the API server was Content-Type: text/html with obviously a 500 error HTML as the body.

I personally think when an error occurs while handling JSON request it should return error response in JSON format, indeed with Content-Type: application/json as the request indicates, yet, this behavior strongly depends on how the API server is implemented, and is not something that client library should be aware of. That said, I think the current error message, "Invalid JSON Response" does not communicate well in such situation, and should show such errors with an error message that better describes what happened.

@edwardkenfox
Copy link
Contributor Author

@degemer Any thoughts on this?

Copy link
Contributor

@masci masci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@masci masci added this to the 1.30 milestone Jun 5, 2018
@masci masci merged commit d492c94 into DataDog:master Jun 5, 2018
@edwardkenfox edwardkenfox deleted the friendly-error-message-for-non-json-response branch June 5, 2018 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants