REST API responses from CinderExceptions are not being translated

Bug #1229967 reported by Luis A. Garcia
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
Luis A. Garcia

Bug Description

Unlike error that result from HTTPExceptions, the error responses that result from CinderExceptions are not being translated anymore.

To reproduce an example:

Try the following request:
POST /v2/{tenant-id}/snapshots
Body:
{"snapshot": {"volume_id": "99"}}
Headers:
Accept-Language: es (or some language installed)
Content-Type: application/json

This will result in the following:

{
    "itemNotFound": {
        "message": "VolumeNotFound: Volume 99 could not be found.",
        "code": 404
    }
}

That is, an English response (or the default locale's) even if the requested locale is available.

PS: Invalid and NotAuthorized CinderExceptions are handled correctly

Luis A. Garcia (luisg-8)
Changed in cinder:
assignee: nobody → Luis A. Garcia (luisg-8)
Luis A. Garcia (luisg-8)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.openstack.org/48308

Changed in cinder:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/48308
Committed: http://github.com/openstack/cinder/commit/a1a898c4667b8e99d733f1391e0d325c8ce6e187
Submitter: Jenkins
Branch: master

commit a1a898c4667b8e99d733f1391e0d325c8ce6e187
Author: Luis A. Garcia <email address hidden>
Date: Tue Sep 24 22:07:55 2013 +0000

    Fix translation of CinderExceptions in REST API

    When creating a Fault from a CinderException wrapped in an
    HTTPException, we were converting the inner explanation to unicode
    before it was able to reach the Fault's call() method which is where
    translation occurs, and unicode objects can't be translated.

    This patch preserves the CinderException's Message object and puts it in
    another Message object as the explanation to the HTTPException so it can
    be translated.

    Fixes bug: #1229967

    Change-Id: Ida71908b639da32b4b85846a117ef21da2fe685b

Changed in cinder:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in cinder:
milestone: none → havana-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in cinder:
milestone: havana-rc1 → 2013.2
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.