TypeError raised when attempting to get invalid image

Bug #1080515 reported by Brian Waldon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-novaclient
Invalid
Low
Anita Kuno

Bug Description

When attempting to call novaclient.v1_1.client.images.get with a non-UUID image id, a TypeError is raised. python-novaclient should raise ImageNotFound instead:

>>> import novaclient.v1_1.client
>>> client = novaclient.v1_1.client.Client('demo', 'secrete', 'demo', 'http://192.168.27.100:5000/v2.0')
>>> client.images.get(name='name with spaces')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: get() got an unexpected keyword argument 'name'
>>> client.images.get('invalid id')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/bcwaldon/.virtualenvwrapper/openstack-clients/lib/python2.7/site-packages/novaclient/v1_1/images.py", line 38, in get
    return self._get("/images/%s" % base.getid(image), "image")
  File "/Users/bcwaldon/.virtualenvwrapper/openstack-clients/lib/python2.7/site-packages/novaclient/base.py", line 142, in _get
    return self.resource_class(self, body[response_key], loaded=True)
TypeError: string indices must be integers, not str

Brian Waldon (bcwaldon)
Changed in python-novaclient:
status: New → Triaged
importance: Undecided → Low
Anita Kuno (anteaya)
Changed in python-novaclient:
assignee: nobody → Anita Kuno (akuno)
Revision history for this message
Anita Kuno (anteaya) wrote :

After a conversation with bcwaldon on irc, my current understanding of the solution to this bug derives from Brian's comment:
"what you want to assert is that a request for an image with a space in the image id translates to a similar string with a %20 in it".

So I will use this information as I move forward.

Thanks Brian,
Anita.

Revision history for this message
Anita Kuno (anteaya) wrote :

To result in an Image Not Found error, I need to assert %2D not %20.

Revision history for this message
Anita Kuno (anteaya) wrote :

Currently my understanding is that novaclient should be checking the format of the image argument, throwing an exception such as CommandError if the argument fails a format check.

With direction from bcwaldon I am currently trying to check the format in find_resource in utils.py.

Revision history for this message
Anita Kuno (anteaya) wrote :

After talking with Vishy on IRC, this bug is closed.

Changed in python-novaclient:
status: Triaged → Invalid
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.