Invalid auth response throws KeyError

Bug #1307306 reported by Jamie Lennox
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-keystoneclient
Fix Released
Medium
Jamie Lennox

Bug Description

If you get back completely incorrect data from an auth request (v2 or v3) then when it tries to decode the body the data is invalid and it cannot find the auth information. eg.

    access.AccessInfoV2(**resp.json()['access'])

fails either because the response isn't json or it doesn't have an access key.

This is something i thought would be well covered because it is not a situation unique to auth, however i can't find an appropriate error to raise in keystoneclient or novaclient.

Revision history for this message
Jamie Lennox (jamielennox) wrote :

Note, that it's definitely an error case, the bug is that it shouldn't be simply a KeyError/TypeError

Changed in python-keystoneclient:
assignee: nobody → Jamie Lennox (jamielennox)
status: New → In Progress
Revision history for this message
Dolph Mathews (dolph) wrote :

Keystone should never return anything but JSON - there's a few edge cases that are still unhandled, but if you've run into a trivial way to get keystone to return non-JSON through the client, we should fix that on the server side as well.

Changed in python-keystoneclient:
importance: Undecided → Medium
Revision history for this message
Jamie Lennox (jamielennox) wrote :

In reality this came up from trying to port the session object to other clients. There was a test somewhere that returned an invalid auth response that there client could handle and i couldn't find any way to identify a similar failure from keystoneclient.

Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix merged to python-keystoneclient (master)

Reviewed: https://review.openstack.org/85213
Committed: https://git.openstack.org/cgit/openstack/python-keystoneclient/commit/?id=4a81a146859cf783c876dc0e8d580333c246596c
Submitter: Jenkins
Branch: master

commit 4a81a146859cf783c876dc0e8d580333c246596c
Author: Jamie Lennox <email address hidden>
Date: Fri Apr 4 11:17:24 2014 +1000

    Add new error for invalid response

    There are a number of places where we expect a certain format of
    response. If it's not found we often end up raising a KeyError when
    accessing data.

    Create a new Exception type that is raised when a HTTP response is not
    appropriate for parsing and use it within authentication calls.

    Closes-Bug: #1307306
    Change-Id: I3cf2db07a8e76ee17702130e9efb0edf640d293a

Changed in python-keystoneclient:
status: In Progress → Fix Committed
Dolph Mathews (dolph)
Changed in python-keystoneclient:
milestone: none → 0.9.0
Dolph Mathews (dolph)
Changed in python-keystoneclient:
status: Fix Committed → Fix Released
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.