malformed server update causes: KeyError: 'server'

Bug #1038227 reported by Dan Prince
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Dan Prince

Bug Description

Posting a malformed update PUT request to the /servers Openstack API will cause the following exception:

From the disk_config extension:

2012-08-17 19:29:20 TRACE nova.api.openstack response = gen.next()
2012-08-17 19:29:20 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/contrib/disk_config.py", line 151, in update
2012-08-17 19:29:20 TRACE nova.api.openstack self._set_disk_config(body['server'])
2012-08-17 19:29:20 TRACE nova.api.openstack KeyError: 'server'
2012-08-17 19:29:20 TRACE nova.api.openstack

From the servers.py core update function:

2012-08-17 19:31:51 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/nova/api/openstack/wsgi.py", line 1000, in dispatch
2012-08-17 19:31:51 TRACE nova.api.openstack return method(req=request, **action_args)
2012-08-17 19:31:51 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/servers.py", line 823, in update
2012-08-17 19:31:51 TRACE nova.api.openstack if 'name' in body['server']:
2012-08-17 19:31:51 TRACE nova.api.openstack KeyError: 'server'
2012-08-17 19:31:51 TRACE nova.api.openstack

----

This causes an HTTP 500 exception. It should return a 422 unprocessable entity.

Dan Prince (dan-prince)
Changed in nova:
assignee: nobody → Dan Prince (dan-prince)
importance: Undecided → Medium
status: New → In Progress
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/11578

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/11578
Committed: http://github.com/openstack/nova/commit/1a605cccb1fe29ae6554ad5afa3110abef11d9c2
Submitter: Jenkins
Branch: master

commit 1a605cccb1fe29ae6554ad5afa3110abef11d9c2
Author: Dan Prince <email address hidden>
Date: Fri Aug 17 15:34:28 2012 -0400

    Return HTTP 422 on bad server update PUT request.

    This patch updates the /servers API and the disk config
    extension so that they properly handle incorrectly formatted
    server update/PUT requests.

    Includes a new test cause that verifies (with extensions enabled)
    that a poorly formatted PUT request to /servers returns HTTP 422
    instead of a 500.

    Also updated the previous test_create_missing_server test to use
    test.TestException instead of Exception.

    Fixes LP Bug #1038227.

    Change-Id: I6b11602790778465348647bb5825b7326d50065a

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