boolean query parameters inconsistently handled

Bug #1267530 reported by Steven Hardy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
Medium
Steven Hardy

Bug Description

The code which handles interpreting boolean query parameters (which are always converted to strings as part of the request) seems overly restrictive, it will only except "blah?parameter=0" as a definition of False, and not the (arguably more intuitive) "blah?parameter=False"

For example, trying to use the domain "enabled" filter:

# curl -i -X GET -H 'X-Auth-Token: 27c9fcf8c0404de0b15f33e11208bdda' -H 'Content-Type: application/json' -H 'Accept: application/json' http://127.0.0.1:5000/v3/domains?enabled=0
HTTP/1.1 200 OK
Vary: X-Auth-Token
Content-Type: application/json
Content-Length: 102
Date: Thu, 09 Jan 2014 16:37:29 GMT

{"domains": [], "links": {"self": "http://localhost:5000/v3/domains", "previous": null, "next": null}}

# curl -i -X GET -H 'X-Auth-Token: 27c9fcf8c0404de0b15f33e11208bdd -H 'Content-Type: application/json' -H 'Accept: application/json' http://127.0.0.1:5000/v3/domains?enabled=False
HTTP/1.1 200 OK
Vary: X-Auth-Token
Content-Type: application/json
Content-Length: 536
Date: Thu, 09 Jan 2014 16:37:35 GMT

{"domains": [{"links": {"self": "http://localhost:5000/v3/domains/b10fcb438ed048ada48036c25f8a45de"}, "enabled": true, "description": "Owns users and tenants used by the heat service", "name": "heat", "id": "b10fcb438ed048ada48036c25f8a45de"}, {"links": {"self": "http://localhost:5000/v3/domains/default"}, "enabled": true, "description": "Owns users and tenants (i.e. projects) available on Identity API v2.", "name": "Default", "id": "default"}], "links": {"self": "http://localhost:5000/v3/domains", "previous": null, "next": null}}

So passing enabled=False returns all the results for enabled=True, which is, uh, confusing, particularly since True/False works when specifying enabled in the body when creating a domain.

The problem is here:
https://github.com/openstack/keystone/blob/master/keystone/common/controller.py#L321

Steven Hardy (shardy)
Changed in keystone:
assignee: nobody → Steven Hardy (shardy)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (master)

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

Dolph Mathews (dolph)
Changed in keystone:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystone (master)

Reviewed: https://review.openstack.org/65725
Committed: https://git.openstack.org/cgit/openstack/keystone/commit/?id=069ef0ad5e3aa73ae58e7dbba2c917e969fa8e1d
Submitter: Jenkins
Branch: master

commit 069ef0ad5e3aa73ae58e7dbba2c917e969fa8e1d
Author: Steven Hardy <email address hidden>
Date: Mon Jan 27 14:26:20 2014 +0000

    Make boolean query filter "False" argument work

    Currently passing parameter=False returns the results
    for parameter=True, so make the boolean evaluation of
    the query string parameter more robust by using
    oslo strutils.bool_from_string

    Change-Id: I189a4f4a2e6448698903b949bdf74d5ef25d338b
    Closes-Bug: #1267530

Changed in keystone:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in keystone:
milestone: none → icehouse-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in keystone:
milestone: icehouse-3 → 2014.1
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.