Error message handling incorrectly accesses error response title

Bug #1474479 reported by Michael Durrant
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-barbicanclient
New
Undecided
Unassigned

Bug Description

barbicanclient/client.py - function _get_error_message lines 107-113:

def _get_error_message(self, resp):
    try:
        response_data = resp.json()
        message = response_data['title']
    except ValueError:
        message = resp.content
    return message

It appears response_data does not always contain a "title" attribute - but if response_data contains an "error" attribute, "error" usually has a title hanging off of it. I express this in uncertain terms as there are probably thousands of potential methods that access this.

I believe the fix is:
  If response_data has an "error" attribute and the "error" attribute has a "title", return "title" as the error message, else return the response content.

I was able to reproduce the error by using the barbican_client_manager in neutron_lbaas and passing "check_only=False" to the get_cert method.

description: updated
description: updated
description: updated
summary: - Error message handling incorrectly accesses error respones title
+ Error message handling incorrectly accesses error response title
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.