Name and Description is storing in DB with leading and trailing spaces

Bug #1742907 reported by Pooja Jadhav
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
Pooja Jadhav

Bug Description

This issue is found in (Backup and Snapshot APIs)

On master before merging patch[1][2], name and description with leading and trailing spaces get
removed in the method "validate_name_and_description" which is under
"https://github.com/openstack/cinder/blob/master/cinder/api/openstack/wsgi.py#L1253-L1264".

After applying schema validation, name and description is not removing leading and trailing spaces
and as it is storing in DB. IMO, it should be fixed.

Steps to reproduce:

1. curl command:

curl -g -i -X POST http://10.232.48.206/volume/v3/63759ee0b57249539af42d95a58032df/backups -H "User-Agent: python-cinderclient" -H "Content-Type: application/json" -H "X-OpenStack-Request-ID: req-3510f84a-51d4-49ec-9d69-0c34f8ffa8dc" -H "Accept: application/json" -H "X-Auth-Token: f517a81cd25a4788a01dd60f76cd6435" -d '{"backup": {"force": true, "description": null, "snapshot_id": null, "incremental": false, "volume_id": "1ae283da-b8cf-44cd-bcc0-751b85c445a6", "container": null, "name": " test", "description": " description "}}'

2. output:

202 Accepted

{"backup": {"id": "04f2abba-cc0b-45a5-9a26-8a88c4d67a12", "links": [{"href": "http://10.232.48.206/volume/v3/63759ee0b57249539af42d95a58032df/backups/04f2abba-cc0b-45a5-9a26-8a88c4d67a12", "rel": "self"}, {"href": "http://10.232.48.206/volume/63759ee0b57249539af42d95a58032df/backups/04f2abba-cc0b-45a5-9a26-8a88c4d67a12", "rel": "bookmark"}], "name": " test"}}

3. curl command:

curl -g -i -X POST http://10.232.48.198/volume/v3/5fe3b884c656498b922d8551c86cb0b0/snapshots -H "X-Auth-Token: 9c754d726df149eb837e4a6c26572117" -H "Accept: application/json" -H "Content-Type: application/json" -H "User-Agent: python-cinderclient" -d '{"snapshot": {"volume_id": "daf9e961-d6dd-41f8-9cb6-4bba0fce8a1c", "name": " abc ", "description": " test_desc "}}'

4. output:

202 Accepted

{"snapshot": {"id": "875e8050-5a53-4a5c-b2a4-d5c372b6b1c8", "name": " abc ", "volume_id": "daf9e961-d6dd-41f8-9cb6-4bba0fce8a1c", "size": 1, "status": "creating", "updated_at": null, "created_at": "2018-01-10T07:29:44.351225", "description": " test_desc ", "metadata": {}}}

[1]https://review.openstack.org/#/c/530098/
[2]https://review.openstack.org/#/c/520991/

Changed in cinder:
assignee: nobody → Pooja Jadhav (poojajadhav)
Changed in cinder:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

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

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

Reviewed: https://review.openstack.org/534184
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=c1356eeca9434ff24a0a5db799d83a7a509f430b
Submitter: Zuul
Branch: master

commit c1356eeca9434ff24a0a5db799d83a7a509f430b
Author: pooja jadhav <email address hidden>
Date: Sun Jan 14 11:48:25 2018 +0530

    Remove leading and trailing spaces from parameters

    Snapshots and backup (create/update) APIs stores 'name' and
    description' parameters with leading and trailing spaces in
    database after patches [1][2] are merged.

    This patch removes leading and trailing whitespaces before
    validation and also before storing it in db for 'name' and
    'description' parameters.

    [1]https://review.openstack.org/#/c/520991/
    [2]https://review.openstack.org/#/c/530098/

    Closes-Bug: #1742907
    Change-Id: Ib5c8d32e2c20cbacebd7b6f7281a44f94a70f7c0

Changed in cinder:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 12.0.0.0b3

This issue was fixed in the openstack/cinder 12.0.0.0b3 development milestone.

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.