Updating the server with invalid name is not raising Bad request

Bug #944034 reported by Rajalakshmi Ganesan on 2012-03-01
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Mike Lundy

Bug Description

Updating the server with invalid name should raise the bad request exception. But it is not raising.

Expected result:
Should raise the bad request

Refernce link:

Changed in nova:
status: New → Triaged
importance: Undecided → Low
tags: added: low-hanging-fruit
Mike Lundy (novas0x2a) on 2012-03-01
Changed in nova:
assignee: nobody → Mike Lundy (novas0x2a)
Mike Lundy (novas0x2a) wrote :

submitter: what invalid name do you mean?

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

Changed in nova:
status: Triaged → In Progress

Reviewed: https://review.openstack.org/4787
Committed: http://github.com/openstack/nova/commit/27013e87f53cccbfd2e203f065e416437ba08987
Submitter: Jenkins
Branch: master

commit 27013e87f53cccbfd2e203f065e416437ba08987
Author: Mike Lundy <email address hidden>
Date: Fri Mar 2 00:15:04 2012 +0000

    Fail gracefully when the db doesn't speak unicode

    When sqlalchemy/mysql doesn't contain the charset=utf8 or use_unicode=1
    parameters (and the default mysql connection charset is not utf8),
    sqlalchemy will connect to mysql in ascii mode; In ascii mode, it will
    attempt to reencode all input data to latin-1 regardless of the
    database/table collation setting. This catches that error and turns it
    into an invalid parameter.

    (The error message associated with this is something like
    UnicodeEncodeError: 'latin-1' codec can't encode character u'\u2026' in
    position 30: ordinal not in range(256))

    This fixes bug 944034 and is related to bug 898808

    Change-Id: I082b7568ef9e9d2104e13aa58d207535ef201bd3

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx) on 2012-03-20
Changed in nova:
milestone: none → essex-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2012-04-05
Changed in nova:
milestone: essex-rc1 → 2012.1
Download full text (9.2 KiB)

I am still able to update servers name with invalid charcaters such ad "&!@#$%^&*()+_"

Thus reopening this bug.


[umamaheshk@HPOpenstackVM16 ~/source/csbu-qa-dev/nova/tests]$nova list
| ID | Name | Status | Networks |
| 16716a61-d8ba-4abb-885d-db10eced1562 | update_server_name | ACTIVE | private= |
| a31aeecd-5237-4e1a-98b1-407164166c3a | test-1 | ACTIVE | private= |
| d496dc20-ef69-4aa6-97c0-798878b635c8 | update_server_name&12!@#$%^&*()+_ | ACTIVE | private= |
[umamaheshk@HPOpenstackVM16 ~/source/csbu-qa-dev/nova/tests]$export NOVACLIENT_DEBUG=1
[umamaheshk@HPOpenstackVM16 ~/source/csbu-qa-dev/nova/tests]$./apitool.py -j update.json PUT /servers/a31aeecd-5237-4e1a-98b1-407164166c3a
REQ: curl -i -X POST -H "Content-Type: application/json" -H "User-Agent: python-novaclient"

REQ BODY: {"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "muralik"}}}

RESP:{'date': 'Fri, 12 Oct 2012 14:16:10 GMT', 'vary': 'X-Auth-Token', 'content-length': '2462', 'status': '200', 'content-type': 'application/json'} {"access": {"token": {"expires": "2012-10-13T14:16:10Z", "id": "0672b716683d4f21a4e46ad8846cc34c", "tenant": {"enabled": true, "description": null, "name": "admin", "id": "bea2e6e7c6d4468281b37f0281d90a65"}}, "serviceCatalog": [{"endpoints": [{"adminURL": "", "region": "RegionOne", "internalURL": "", "id": "4d2bd52566f449b681d138970d0551a9", "publicURL": ""}], "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": "", "region": "RegionOne", "internalURL": "", "id": "96a896eefefd435d9eb171f5193f6ffc", "publicURL": ""}], "endpoints_links": [], "type": "s3", "name": "s3"}, {"endpoints": [{"adminURL": "", "region": "RegionOne", "internalURL": "", "id": "3744aa8ba7e444d4bc88e92edce85336", "publicURL": ""}], "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": "", "region": "RegionOne", "internalURL": "", "id": "40062dde5eef4d7091d8d2e034cc3858", "publicURL": ""}], "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": [{"adminURL": "", "region": "RegionOne", "internalURL": "http://10.2...


Changed in nova:
status: Fix Released → New
status: New → In Progress

There's nothing in the doc [1] that says characters in "&!@#$%^&*()+_" are invalid. we throw Bad Request only under the following conditions [2]

[1] http://docs.openstack.org/api/openstack-compute/1.1/content/ServerUpdate.html
[2] validation code
    def _validate_server_name(self, value):
        if not isinstance(value, basestring):
            msg = _("Server name is not a string or unicode")
            raise exc.HTTPBadRequest(explanation=msg)

        if not value.strip():
            msg = _("Server name is an empty string")
            raise exc.HTTPBadRequest(explanation=msg)

        if not len(value) < 256:
            msg = _("Server name must be less than 256 characters.")
            raise exc.HTTPBadRequest(explanation=msg)

Changed in nova:
status: In Progress → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers