RestClient assumes too much about error bodies

Bug #1022727 reported by David Kranz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tempest
Fix Released
Medium
David Kranz

Bug Description

While trying to remove the skips from the identity tests I discovered this general bug. The particular case I found was this code:

        if resp.status == 400:
            resp_body = json.loads(resp_body)
            self._log(req_url, body, resp, resp_body)
            raise exceptions.BadRequest(resp_body['badRequest']['message'])

This assumes that the response body is nested json tagged by "badRequest" and then "message" which is what nova does. It seems that 400 errors from keystone give ["error"]["message"]. We could abstract this behavior into a RestClient method that could be overridden by specific client, but I don't think we should be relying on this at all. It is not part of the spec as far as I can see. I think it would be better to just put the raw json string as the message "body". Comments?

Revision history for this message
Jay Pipes (jaypipes) wrote :

Yeah, this is true. I fixed this up for the 500 error series (looking up various things like 'computeFault', 'cloudServersFault', and 'error' keys in the returned body).

You can go either route I suppose... or do something like check for 'badRequest in body, and if so, grab the message, if not just dump the body text/json to the exception raised.

Changed in tempest:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
David Kranz (david-kranz) wrote :

I had to submit code that just dumps the body for 404 to make the skipped tests work. Most of the exceptions do this anyway. I don't see much value in doing anything else. It is just not part of the spec.

Changed in tempest:
assignee: nobody → David Kranz (david-kranz)
Revision history for this message
Jay Pipes (jaypipes) wrote :

We can mark this fix committed then, since your skip patch is now in trunk...

Changed in tempest:
status: Triaged → Fix Committed
Jay Pipes (jaypipes)
Changed in tempest:
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.