[openstack-dev] [nova] How to fix the wrong usage of 'format' jsonschema keyword in server create API

Alex Xu soulxu at gmail.com
Mon Mar 7 13:05:28 UTC 2016


2016-03-07 19:23 GMT+08:00 Sean Dague <sean at dague.net>:

> On 03/07/2016 01:18 AM, Alex Xu wrote:
> > Hi,
> >
> > Due to this regression bug https://launchpad.net/bugs/1552888, found we
> > are using 'formart' jsonschema keyword in wrong way. The 'format' is not
> > only for string instance, but all the types.
>
> Can you given an example of the kinds of things that are currently being
> rejected? And if we think those REST API calls are valid? I'd like to
> know what we started blocking in Option 3 that no one noticed until now.
>
>
In the legacy v2 API, we create server with network like this:
"networks": [{"uuid": "f4001fde-7bb8-4a73-b1a9-03b444d1f6f8", "port":
null}]'
The port can be null.

With v2.1 API, you will get 400:

curl -g -i -X POST
http://192.168.2.176:8774/v2.1/b90b53ed87d74e19806da34dbaa056c9/servers -H
"User-Agent: python-novaclient" -H "Content-Type: application/json" -H
"Accept: application/json" -H "X-Auth-Token:
e740965218754560a98d9ac188271253" -d '{"server": {"name": "vm4",
"imageRef": "33a713dc-7efe-488c-bf12-d902ff5e6118", "flavorRef": "1",
"max_count": 1, "min_count": 1, "networks": [{"uuid":
"f4001fde-7bb8-4a73-b1a9-03b444d1f6f8", "port": null}]}}'
HTTP/1.1 400 Bad Request
X-Openstack-Nova-Api-Version: 2.1
Vary: X-OpenStack-Nova-API-Version
Content-Type: application/json; charset=UTF-8
Content-Length: 117
X-Compute-Request-Id: req-c5ab91ca-dc24-42ea-8272-7f35571b15da
Date: Mon, 07 Mar 2016 13:01:58 GMT

{"badRequest": {"message": "Invalid input for field/attribute port. Value:
None. None is not a 'uuid'", "code": 400}}

This is due to we write json-schema like this:
'port': {
       'type': ['string', 'null'],
       format': 'uuid'
 },


We assume 'type' will enable 'null' value and 'format' only against on
string type. Actually 'null' will be passed to format check also, then the
format check return fault.




>         -Sean
>
> --
> Sean Dague
> http://dague.net
>
>
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20160307/41518a53/attachment.html>


More information about the OpenStack-dev mailing list