strings are being treated as numbers

Bug #1371924 reported by Alun Champion
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-openstackclient
Fix Released
Undecided
wanghong

Bug Description

The openstack cli is incorrectly handling strings when converting from name, e.g. a user with the name 012345 cannot be directly shown.

openstack> user show 012345
Could not find user, 12345. (HTTP 404)
openstack> user show "012345"
Could not find user, 12345. (HTTP 404)

Looks like it is interpreting it is a number and then converting to a string.

However an ID with a leading 0 works fine.

openstack> user show 00aa8edab2112302906b246c65ee24e8
Works

wanghong (w-wanghong)
Changed in python-openstackclient:
assignee: nobody → wanghong (w-wanghong)
Revision history for this message
wanghong (w-wanghong) wrote :

This is because "012345".isdigit() is True and keystoneclient raises HTTPClientError(https://github.com/openstack/python-keystoneclient/blob/master/keystoneclient/openstack/common/apiclient/exceptions.py#L462) rather than NotFound. So, the code https://github.com/openstack/python-openstackclient/blob/master/openstackclient/common/utils.py#L35 can not catch the excepted exception.

Revision history for this message
wanghong (w-wanghong) wrote :

Correct the error in the last comment: keystoneclient did raise NotFound but the NotFound raised by keystoneclient does not equal with the NotFound in openstackclient.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-openstackclient (master)

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

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

Reviewed: https://review.openstack.org/123621
Committed: https://git.openstack.org/cgit/openstack/python-openstackclient/commit/?id=7029cf37e268a789a65bab3b9a16e4491854106e
Submitter: Jenkins
Branch: master

commit 7029cf37e268a789a65bab3b9a16e4491854106e
Author: wanghong <email address hidden>
Date: Wed Sep 24 11:04:41 2014 +0800

    utils.find_resource does not catch right exception

    Currently, utils.find_resource catch NotFound exception defined in
    openstackclient. However, different client libraries raise different
    exceptions defined in thire own library.

    Change-Id: Idc40428e30e59f71dbdbfa0555c0066fddc441c2
    Closes-Bug: #1371924

Changed in python-openstackclient:
status: In Progress → Fix Committed
Dean Troyer (dtroyer)
Changed in python-openstackclient:
milestone: none → m6
Dean Troyer (dtroyer)
Changed in python-openstackclient:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.