REST API didn't verify json data format

Bug #1379973 reported by Yang Ye
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Christopher Yeoh

Bug Description

When try to create a server with REST API, I set attribute block_device_mapping with wrong value, not a list<dict> but a string (from "block_device_mapping": [{"volume_id": "1", "delete_on_termination": "0", "device_name": "/dev/vdb"}] to "block_device_mapping": "abc",). And then I got a response with code 500.
In nova CLI, when params are wrong you will get a notice, but in REST you get nothing.
If openstack use json schema to describe every REST API and verify json requested , users can easily know how to use these API and which attribute was wrong.

Revision history for this message
Christopher Yeoh (cyeoh-0) wrote :

Confirmed this is an issue. json schema is being introduced as part of v2.1 but we can still patch v2

Changed in nova:
status: New → Confirmed
assignee: nobody → Christopher Yeoh (cyeoh-0)
Changed in nova:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/127860
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=d6bf0d06c3bedcdeb211b563cf0923764b411966
Submitter: Jenkins
Branch: master

commit d6bf0d06c3bedcdeb211b563cf0923764b411966
Author: Chris Yeoh <email address hidden>
Date: Mon Oct 13 11:25:39 2014 +1030

    Add more input validation of bdm param in server creation

    Adds a check to ensure that block_device_mapping is a list and
    return 400 Bad Request rather than 500 as currently happens.

    Change-Id: I30551bcbb7d658734da158dbb8dd7d825c526896
    Closes-Bug: 1379973

Changed in nova:
status: In Progress → Fix Committed
Revision history for this message
Yang Ye (ccyangye) wrote :

Return 500 is not good, but I think it's bearable. It's not necessary to write a piece of code to check only this because there're hundreds of json inputs. I prefer to use json schema. But thank you any way.

Revision history for this message
Christopher Yeoh (cyeoh-0) wrote :

So for v2.1 we will eventually have json schema coverage - its just not there for that plugin yet but is for many others. But for v2 we don't support jsonschema and need an explicit check. The V2.1 check was added a stop-gap until the schema for that method is implemented. We don't want 500's occurring because they cause big LOG messages.

Thierry Carrez (ttx)
Changed in nova:
milestone: none → kilo-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: kilo-1 → 2015.1.0
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.