Comment 6 for bug 1718877

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/ocata)

Reviewed: https://review.openstack.org/506760
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=befcda5b2149492cf6b5c7856def238fbb9079d8
Submitter: Jenkins
Branch: stable/ocata

commit befcda5b2149492cf6b5c7856def238fbb9079d8
Author: Dinesh Bhor <email address hidden>
Date: Tue Sep 19 14:56:01 2017 +0530

    Fix 500 if list servers called with empty regex pattern

    If nova list API is called with empty regex pattern like below:
        http://<host-ip>/compute/v2.1/servers?name=""

    it fails at db layer and returns 500 InternalServerError.

    Empty string('') is a valid regex for re.compile [1] so nova-api fails
    to catch it at schema layer and it is passed to databse for searching.
    Database fails to search it with "REGEXP %(display_name_1)s)" and
    'display_name_1' as u'' in sql query which leads to below error:

    InternalError: (1139, u"Got error 'empty (sub)expression' from regexp")

    This issue is there for every query parameter which is using below
    regex parameter types defined in parameter_types.py:
        common_query_regex_param

    This patch fixes this issue by rejecting the request with 400 if the
    provided filter regex is empty string. If user is intending to filter
    something, user must pass something to the filter, it cannot be a empty
    string.

    [1] https://github.com/openstack/nova/blob/16.0.0/nova/api/validation/validators.py#L40

    Closes-Bug: #1718877
    Change-Id: I3f6fa04dc7267279964e8e5dd2a790b997a40e4e
    (cherry picked from commit 0cc94bfd5934e793cb8d739e132b52fa40bcddb0)
    (cherry picked from commit 6538175c08f127c20e72e1d347af3eb3d54d6838)