v2 API responce doesn't follow documentation for not defined values

Bug #1481512 reported by Ilya Sviridov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Invalid
Undecided
Unassigned
openstack-api-site
Fix Released
Undecided
Ilya Sviridov

Bug Description

Calling image list functionality for v2 API the JSON null value is returned for not defined fields in response, instead expecting string 'None' according to documentation http://developer.openstack.org/api-ref-image-v2.html

"If this field has no value, its value is None. "

Glance code revision:
ubuntu@ubuntu:/opt/stack/glance$ git show
commit fbb5e1c440933860da10cd526daca3ad7b63782c
Merge: aeb3c6a 643ad31
Author: Jenkins <email address hidden>
Date: Wed Jul 15 00:10:28 2015 +0000

    Merge "Purge dead file-backed scrubber queue code"

Request:
http://127.0.0.1:9292/v2/images?limit=100

Response:

{
    "images": [
        {
            "status": "queued",
            "name": "TestImage",
            "tags": [],
            "container_format": "ami",
            "created_at": "2015-08-01T17:29:52Z",
            "size": null,
            "disk_format": "ami",
            "updated_at": "2015-08-01T17:29:52Z",
            "visibility": "private",
            "self": "/v2/images/147824e3-0406-48d4-a064-58f9c5bd8534",
            "min_disk": 0,
            "protected": false,
            "id": "147824e3-0406-48d4-a064-58f9c5bd8534",
            "file": "/v2/images/147824e3-0406-48d4-a064-58f9c5bd8534/file",
            "checksum": null,
            "owner": "d8ec44f4c4bd4799af7b1c0c8158a8c8",
            "virtual_size": null,
            "min_ram": 0,
            "schema": "/v2/schemas/image"
        },
        {
            "status": "queued",
            "name": "TestImage",
            "tags": [],
            "container_format": "ami",
            "created_at": "2015-08-01T17:29:41Z",
            "size": null,
            "disk_format": "ami",
            "updated_at": "2015-08-01T17:29:41Z",
            "visibility": "private",
            "self": "/v2/images/bc952044-248f-4e4c-b720-2ef337642658",
            "min_disk": 0,
            "protected": false,
            "id": "bc952044-248f-4e4c-b720-2ef337642658",
            "file": "/v2/images/bc952044-248f-4e4c-b720-2ef337642658/file",
            "checksum": null,
            "owner": "d8ec44f4c4bd4799af7b1c0c8158a8c8",
            "virtual_size": null,
            "min_ram": 0,
            "schema": "/v2/schemas/image"
        },
        {
            "status": "queued",
            "name": "TestImage",
            "tags": [],
            "container_format": "ami",
            "created_at": "2015-08-01T17:29:32Z",
            "size": null,
            "disk_format": "ami",
            "updated_at": "2015-08-01T17:29:32Z",
            "visibility": "private",
            "self": "/v2/images/0307f138-a722-4561-aa69-c48ca481d371",
            "min_disk": 0,
            "protected": false,
            "id": "0307f138-a722-4561-aa69-c48ca481d371",
            "file": "/v2/images/0307f138-a722-4561-aa69-c48ca481d371/file",
            "checksum": null,
            "owner": "d8ec44f4c4bd4799af7b1c0c8158a8c8",
            "virtual_size": null,
            "min_ram": 0,
            "schema": "/v2/schemas/image"
        },
        {
            "container_format": "aki",
            "min_ram": 0,
            "ramdisk_id": "8c64f48a-45a3-4eaa-adff-a8106b6c005b",
            "updated_at": "2015-08-01T03:52:09Z",
            "file": "/v2/images/c77a2e19-b560-4eec-8986-fcd470b5ee0e/file",
            "owner": "d8ec44f4c4bd4799af7b1c0c8158a8c8",
            "id": "c77a2e19-b560-4eec-8986-fcd470b5ee0e",
            "size": 12501760,
            "self": "/v2/images/c77a2e19-b560-4eec-8986-fcd470b5ee0e",
            "disk_format": "aki",
            "schema": "/v2/schemas/image",
            "status": "active",
            "description": "Just a test image",
            "tags": [],
            "kernel_id": "e1b6edd4-bd9b-40ac-b010-8a6c16de4ba4",
            "visibility": "private",
            "min_disk": 0,
            "virtual_size": null,
            "name": "test-image",
            "checksum": "0b9c6d663d8ba4f63733e53c2389c6ef",
            "created_at": "2015-08-01T03:52:05Z",
            "protected": false,
            "architecture": "32bit"
        },
        {
            "status": "active",
            "name": "cirros-0.3.4-x86_64-uec",
            "tags": [],
            "kernel_id": "e1b6edd4-bd9b-40ac-b010-8a6c16de4ba4",
            "container_format": "ami",
            "created_at": "2015-07-15T11:43:35Z",
            "ramdisk_id": "8c64f48a-45a3-4eaa-adff-a8106b6c005b",
            "disk_format": "ami",
            "updated_at": "2015-07-15T11:43:35Z",
            "visibility": "public",
            "self": "/v2/images/07aa21a9-fa1a-430e-9a33-185be5982431",
            "min_disk": 0,
            "protected": false,
            "id": "07aa21a9-fa1a-430e-9a33-185be5982431",
            "size": 25165824,
            "file": "/v2/images/07aa21a9-fa1a-430e-9a33-185be5982431/file",
            "checksum": "eb9139e4942121f22bbc2afc0400b2a4",
            "owner": "cba624273b8344e59dd1fd18685183b0",
            "virtual_size": null,
            "min_ram": 0,
            "schema": "/v2/schemas/image"
        },
        {
            "status": "active",
            "name": "cirros-0.3.4-x86_64-uec-ramdisk",
            "tags": [],
            "container_format": "ari",
            "created_at": "2015-07-15T11:43:32Z",
            "size": 3740163,
            "disk_format": "ari",
            "updated_at": "2015-07-15T11:43:32Z",
            "visibility": "public",
            "self": "/v2/images/8c64f48a-45a3-4eaa-adff-a8106b6c005b",
            "min_disk": 0,
            "protected": false,
            "id": "8c64f48a-45a3-4eaa-adff-a8106b6c005b",
            "file": "/v2/images/8c64f48a-45a3-4eaa-adff-a8106b6c005b/file",
            "checksum": "be575a2b939972276ef675752936977f",
            "owner": "cba624273b8344e59dd1fd18685183b0",
            "virtual_size": null,
            "min_ram": 0,
            "schema": "/v2/schemas/image"
        },
        {
            "status": "active",
            "name": "cirros-0.3.4-x86_64-uec-kernel",
            "tags": [],
            "container_format": "aki",
            "created_at": "2015-07-15T11:43:29Z",
            "size": 4979632,
            "disk_format": "aki",
            "updated_at": "2015-07-15T11:43:30Z",
            "visibility": "public",
            "self": "/v2/images/e1b6edd4-bd9b-40ac-b010-8a6c16de4ba4",
            "min_disk": 0,
            "protected": false,
            "id": "e1b6edd4-bd9b-40ac-b010-8a6c16de4ba4",
            "file": "/v2/images/e1b6edd4-bd9b-40ac-b010-8a6c16de4ba4/file",
            "checksum": "8a40c862b5735975d82605c1dd395796",
            "owner": "cba624273b8344e59dd1fd18685183b0",
            "virtual_size": null,
            "min_ram": 0,
            "schema": "/v2/schemas/image"
        }
    ],
    "schema": "/v2/schemas/images",
    "first": "/v2/images?limit=100"
}

Revision history for this message
Stuart McLaren (stuart-mclaren) wrote :

I think this is a case of the documentation being wrong. I think the docs should say 'null'.

Revision history for this message
Ian Cordasco (icordasc) wrote :

I agree with Stuart. In Python if you do

    import json

    json.dumps({'Some Key': None})

You get a string like

    '{"Some Key": null}'

Because None in Python is equivalent to null in JavaScript. That said, this bug then belongs on a different project, not on Glance.

Changed in openstack-api-site:
status: New → Confirmed
Changed in glance:
status: New → Invalid
Changed in openstack-api-site:
assignee: nobody → Ilya Sviridov (isviridov)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to api-site (master)

Fix proposed to branch: master
Review: https://review.openstack.org/211285

Changed in openstack-api-site:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to api-site (master)

Reviewed: https://review.openstack.org/211285
Committed: https://git.openstack.org/cgit/openstack/api-site/commit/?id=94cfc6e22143d9d63fb62955b2356aaaa8f4c044
Submitter: Jenkins
Branch: master

commit 94cfc6e22143d9d63fb62955b2356aaaa8f4c044
Author: Ilya Sviridov <email address hidden>
Date: Mon Aug 10 10:53:28 2015 -0700

    OpenStack Image V2 API documentation

    Changed None values to null

    Change-Id: I9e926c9f91004e7631d9ab6d58ad1f85758d22c0
    Closes-Bug: #1481512

Changed in openstack-api-site:
status: In Progress → Fix Released
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.