Merge "Check response type in _extract_error_json"

This commit is contained in:
Zuul 2020-04-16 08:22:01 +00:00 committed by Gerrit Code Review
commit e6288837d4
2 changed files with 9 additions and 1 deletions

View File

@ -60,7 +60,10 @@ def _extract_error_json_text(body_json):
def _extract_error_json(body, resp):
"""Return error_message from the HTTP response body."""
content_type = resp.headers.get("Content-Type", "")
try:
content_type = resp.headers.get("Content-Type", "")
except AttributeError:
content_type = ""
if content_type.startswith("application/json"):
try:
body_json = resp.json()

View File

@ -0,0 +1,5 @@
---
fixes:
- |
[`bug 1870264 <https://bugs.launchpad.net/python-magnumclient/+bug/1870264>`_]
Fixed bug where the error message from the response could not be parsed.