[openstack-dev] [nova] How to fix the wrong usage of 'format' jsonschema keyword in server create API
Jay Pipes
jaypipes at gmail.com
Mon Mar 7 13:10:17 UTC 2016
On 03/07/2016 08:05 AM, Alex Xu wrote:
> 2016-03-07 19:23 GMT+08:00 Sean Dague <sean at dague.net
> <mailto:sean at dague.net>>:
>
> On 03/07/2016 01:18 AM, Alex Xu wrote:
> > Hi,
> >
> > Due to this regression bughttps://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.
So, 'null' should be removed from there and the required set of
attributes should have 'uuid' removed. Is that correct?
If so, I think it should be fine to correct it without a microversion.
Best,
-jay
More information about the OpenStack-dev
mailing list