conflict with "get" method when props are resources

Bug #1431124 reported by Brian Curtin
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack SDK
Won't Fix
High
Brian Curtin

Bug Description

In the process of doing an attribute access on the id of a resource.prop that is an ID and has type=resource, because of our overloaded use of the "get" function, we end up trying to make a HTTP GET instead of dictionary get.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/brian/rackspace/openstack/python-openstacksdk/openstack/image/v2/tag.py", line 53, in create
    return self._call(session.put)
  File "/Users/brian/rackspace/openstack/python-openstacksdk/openstack/image/v2/tag.py", line 34, in _call
    {"image_id": self._get_id(self.image)}, tag)
  File "/Users/brian/rackspace/openstack/python-openstacksdk/openstack/resource.py", line 462, in _get_id
    return value.id
  File "/Users/brian/rackspace/openstack/python-openstacksdk/openstack/resource.py", line 392, in id
    return self._attrs.get(self.id_attribute, None)
  File "/Users/brian/rackspace/openstack/python-openstacksdk/openstack/resource.py", line 619, in get
    include_headers=include_headers)
  File "/Users/brian/rackspace/openstack/python-openstacksdk/openstack/resource.py", line 572, in get_data_by_id
    response = session.get(url, service=cls.service)
AttributeError: 'str' object has no attribute 'get'

We should be more defensive, either checking if it's a resource or using subscript notation instead.

Revision history for this message
Terry Howe (thowe-g) wrote :

I saw this one too, but it seemed like it was my own fault. The thing is it is a really confusing error until you finally look up the stack trace.

Revision history for this message
Brian Curtin (brian.curtin) wrote :

Yeah, this is what you had shown me once after running that server_builder, which I couldn't reproduce. I got this while toying around in the interpreter, but was dumb enough to clear my screen after it to lose what I had done. I'm still trying to reproduce it, but at least we have a traceback.

Revision history for this message
Terry Howe (thowe-g) wrote :

Are we done with this problem?

Changed in python-openstacksdk:
status: In Progress → Fix Released
status: Fix Released → Incomplete
Revision history for this message
Brian Curtin (brian.curtin) wrote :

I think we are, or at least I haven't seen it. Can reopen if we come across it again.

Changed in python-openstacksdk:
status: Incomplete → Won't Fix
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.