XML serialization fails when it's trying to serialize an empty selector

Bug #1223358 reported by Andrea Rosa
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Andrea Rosa

Bug Description

The XML serilaziation is failing when it's trying to create a datum selector with no values.
It's possible to use devstack to reproduce this issue following these steps:
- boot an instance from volume without specifying an image id:
 nova boot --flavor 1 --block-device-mapping vda=<VOL_ID> inst1
- perform a GET servers for the instance created in the previous step requiring the results in XML:
curl -i http://10.0.0.5:8774/v2/<Tenant_id>/servers/<inst1_uuid> -X GET
-H "X-Auth-Project-Id: admin" -H "Accept: application/xml" -H "X-Auth-Token: <TOKEN>"
The response is a 500 error:
HTTP/1.1 500 Internal Server Error
Content-Length: 192
Content-Type: application/xml; charset=UTF-8
X-Compute-Request-Id: req-5f69cdc2-7b10-4832-89e6-9500601d3ec7
Date: Tue, 10 Sep 2013 13:43:30 GMT

<computeFault code="500" xmlns="http://docs.openstack.org/compute/api/v1.1"><message>The server has either erred or is incapable of performing the requested operation.</message></computeFault>

And in the compute log you can find details of the exception:

2013-09-10 13:43:30.729 ERROR nova.api.openstack [req-5f69cdc2-7b10-4832-89e6-9500601d3ec7 admin admin] Caught error: string indices must be integers, not str
2013-09-10 13:43:30.729 TRACE nova.api.openstack Traceback (most recent call last):
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/__init__.py", line 111, in __call__
2013-09-10 13:43:30.729 TRACE nova.api.openstack return req.get_response(self.application)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1296, in send
2013-09-10 13:43:30.729 TRACE nova.api.openstack application, catch_exc_info=False)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1260, in call_application
2013-09-10 13:43:30.729 TRACE nova.api.openstack app_iter = application(self.environ, start_response)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
2013-09-10 13:43:30.729 TRACE nova.api.openstack return resp(environ, start_response)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/opt/stack/python-keystoneclient/keystoneclient/middleware/auth_token.py", line 534, in __call__
2013-09-10 13:43:30.729 TRACE nova.api.openstack return self.app(env, start_response)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
2013-09-10 13:43:30.729 TRACE nova.api.openstack return resp(environ, start_response)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
2013-09-10 13:43:30.729 TRACE nova.api.openstack return resp(environ, start_response)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/usr/lib/python2.7/dist-packages/routes/middleware.py", line 131, in __call__
2013-09-10 13:43:30.729 TRACE nova.api.openstack response = self.app(environ, start_response)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
2013-09-10 13:43:30.729 TRACE nova.api.openstack return resp(environ, start_response)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 130, in __call__
2013-09-10 13:43:30.729 TRACE nova.api.openstack resp = self.call_func(req, *args, **self.kwargs)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 195, in call_func
2013-09-10 13:43:30.729 TRACE nova.api.openstack return self.func(req, *args, **kwargs)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/wsgi.py", line 904, in __call__
2013-09-10 13:43:30.729 TRACE nova.api.openstack content_type, body, accept)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/wsgi.py", line 993, in _process_stack
2013-09-10 13:43:30.729 TRACE nova.api.openstack self.default_serializers)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/wsgi.py", line 604, in serialize
2013-09-10 13:43:30.729 TRACE nova.api.openstack response.body = serializer.serialize(self.obj)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/xmlutil.py", line 591, in serialize
2013-09-10 13:43:30.729 TRACE nova.api.openstack elem = self.make_tree(obj)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/xmlutil.py", line 619, in make_tree
2013-09-10 13:43:30.729 TRACE nova.api.openstack return self._serialize(None, obj, siblings, nsmap)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/xmlutil.py", line 574, in _serialize
2013-09-10 13:43:30.729 TRACE nova.api.openstack self._serialize(elem, datum, nieces)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/xmlutil.py", line 555, in _serialize
2013-09-10 13:43:30.729 TRACE nova.api.openstack elems = siblings[0].render(parent, obj, siblings[1:], nsmap)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/xmlutil.py", line 427, in render
2013-09-10 13:43:30.729 TRACE nova.api.openstack elems.append((self._render(parent, datum, patches, nsmap), datum))
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/xmlutil.py", line 381, in _render
2013-09-10 13:43:30.729 TRACE nova.api.openstack self.apply(elem, datum)
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/xmlutil.py", line 346, in apply
2013-09-10 13:43:30.729 TRACE nova.api.openstack elem.set(key, unicode(value(obj, True)))
2013-09-10 13:43:30.729 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/xmlutil.py", line 85, in __call__
2013-09-10 13:43:30.729 TRACE nova.api.openstack obj = obj[elem]
2013-09-10 13:43:30.729 TRACE nova.api.openstack TypeError: string indices must be integers, not str

Tags: api
description: updated
Changed in nova:
assignee: nobody → Andrea Rosa (andrea-rosa-m)
tags: added: api
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

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

Reviewed: https://review.openstack.org/46086
Committed: http://github.com/openstack/nova/commit/902184f5dad8334c07e5bee0050376cdfc26f62c
Submitter: Jenkins
Branch: master

commit 902184f5dad8334c07e5bee0050376cdfc26f62c
Author: Andrea Rosa <email address hidden>
Date: Wed Sep 11 16:24:09 2013 +0100

    Fix empty selector XML bug

    The XML serialization fails when it's trying to create a datum selector with no
    values. In that case the obj is an empty string so the selection of datum from
    it just fails.
    Instead of raising an exception the fix is returning an empty string, that
    allows to serialize Selector with an empty object.

    Fixes bug 1223358

    Change-Id: If5d564c9b037eb0a107f4688ffa1aceb5281dc42

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
milestone: none → icehouse-2
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: icehouse-2 → 2014.1
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.