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

Handle scenarios where response body contains unparseable JSON #186

Merged
merged 1 commit into from
May 15, 2020

Conversation

mkanoor
Copy link
Contributor

@mkanoor mkanoor commented May 7, 2020

If the response body contains an invalid JSON we should not raise an exception. Usually happens if the server ran into some error and couldn't send back a valid response body. These are typically the 5xx errors, server side errors.

e.g this is live data that came back from the RBAC service

{"@timestamp":"2020-05-07T08:52:38.780751 ","hostname":"catalog-api-89-46qw4","pid":27,"tid":"2ad1404721ec","level":"err","message":"RBACApiClient::ApiError: Error message: the server returns an error\nHTTP status code: 500\nResponse headers: {\"Server\"=\u003e\"gunicorn/19.9.0\", \"Date\"      =\u003e\"Thu, 07 May 2020 08:52:38 GMT\", \"Connection\"=\u003e\"keep-alive\", \"Content-Type\"=\u003e\"text/html\", \"Content-Length\"=\u003e\"2      7\", \"Vary\"=\u003e\"Origin\"}\nResponse body: \u003ch1\u003eServer Error (500)\u003c/h1\u003e ","request_id":"e2a456005ece40209f01ef5abb5a40de"
{"@timestamp":"2020-05-07T08:52:38.803570 ","hostname":"catalog-api-89-46qw4","pid":27,"tid":"2ad1404721ec","level":"crit","message":"JSON::ParserError (783: unexpected token at '\u003ch1\u003eServer Error (500)\u003c/h1\u003e'):"}

@mkanoor mkanoor requested review from lindgrenj6 and syncrou May 7, 2020 16:00
@lindgrenj6 lindgrenj6 merged commit 121e404 into RedHatInsights:master May 15, 2020
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.

None yet

3 participants