An Unexpected API Error return when call nova v3 api with not enough parameters

Bug #1253089 reported by Ivan-Zhu
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Ivan-Zhu

Bug Description

when port the following test into v3:
        meta = {'meta1': 'data1'}
        self.assertRaises(exceptions.BadRequest,
                          self.client.set_server_metadata,
                          self.server_id, meta=meta, no_metadata_field=True)
The post body will be empty.

when the following action in server_metadata, receive the request will raise a TypeError, but expected_errors will return response with code 500. I think it should be BadRequest (code 400) like v2 api.
 def update_all(self, req, server_id, body):

the following is the nova log:
2013-11-20 21:44:44.893 DEBUG routes.middleware [-] Matched PUT /servers/92875aa6-fe0a-47ed-91ec-ff178b0f8de5/metadata from (pid=32588) __call__ /usr/lib/python2.7/dist-packages/routes/middleware.py:100
2013-11-20 21:44:44.893 DEBUG routes.middleware [-] Route path: '/servers/{server_id}/metadata', defaults: {'action': u'update_all', 'controller': <nova.api.openstack.wsgi.Resource object at 0x4083e50>} from (pid=32588) __call__ /usr/lib/python2.7/dist-packages/routes/middleware.py:102
2013-11-20 21:44:44.894 DEBUG routes.middleware [-] Match dict: {'action': u'update_all', 'server_id': u'92875aa6-fe0a-47ed-91ec-ff178b0f8de5', 'controller': <nova.api.openstack.wsgi.Resource object at 0x4083e50>} from (pid=32588) __call__ /usr/lib/python2.7/dist-packages/routes/middleware.py:103
2013-11-20 21:44:44.896 DEBUG nova.api.openstack.wsgi [req-42c461b8-6104-4a00-89c2-0d7d2a313735 demo demo] Empty body provided in request from (pid=32588) get_body /opt/stack/nova/nova/api/openstack/wsgi.py:841
2013-11-20 21:44:44.897 DEBUG nova.api.openstack.wsgi [req-42c461b8-6104-4a00-89c2-0d7d2a313735 demo demo] Calling method <bound method ServerMetadataController.update_all of <nova.api.openstack.compute.plugins.v3.server_metadata.ServerMetadataController object at 0x40832d0>> from (pid=32588) _process_stack /opt/stack/nova/nova/api/openstack/wsgi.py:964
2013-11-20 21:44:44.897 ERROR nova.api.openstack.extensions [req-42c461b8-6104-4a00-89c2-0d7d2a313735 demo demo] Unexpected exception in API method
2013-11-20 21:44:44.897 TRACE nova.api.openstack.extensions Traceback (most recent call last):
2013-11-20 21:44:44.897 TRACE nova.api.openstack.extensions File "/opt/stack/nova/nova/api/openstack/extensions.py", line 470, in wrapped
2013-11-20 21:44:44.897 TRACE nova.api.openstack.extensions return f(*args, **kwargs)
2013-11-20 21:44:44.897 TRACE nova.api.openstack.extensions TypeError: update_all() takes exactly 4 arguments (3 given)
2013-11-20 21:44:44.897 TRACE nova.api.openstack.extensions
2013-11-20 21:44:44.898 INFO nova.api.openstack.wsgi [req-42c461b8-6104-4a00-89c2-0d7d2a313735 demo demo] HTTP exception thrown: Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.
<type 'exceptions.TypeError'>

Ivan-Zhu (ivan-zhu)
Changed in nova:
assignee: nobody → Ivan-Zhu (ivan-zhu)
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/57447

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/57447
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=8f3d312a98dfa3f8a077b539d7d1adc5f3377987
Submitter: Jenkins
Branch: master

commit 8f3d312a98dfa3f8a077b539d7d1adc5f3377987
Author: ivan-zhu <email address hidden>
Date: Wed Nov 20 22:34:49 2013 +0800

    pass the empty body into the controller

    This allows POST and PUT reqeusts without content-body. The
    default body: None will be passed into the controller, and
    will be validated in the controller, so it fixes the bug 1253089.

    When the request method is GET or DELETE, the content-type
    and body in the request will be ignored
    .
    When POST or PUT a request with body but without content-type,
    it will return "unsupported the content-type provided" with
    response code 400.

    side-effect: The method which handle the request method: POST
    or PUT must have the parameter: body. Otherwise, it will raise:
    "got an unexpected keyword argument 'body'"

    And some tests are updated due to this change.
    The parameter: body are also added for some actions which are
    mapped to the method: POST or PUT.

    Closes-bug: 1253089

    Change-Id: Icda59feed439625bbbe079444feeda57576ef131

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.