osc_lib attempts string actions on int objects when determining auth API version

Bug #1634986 reported by Jesse Keating
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-openstackclient
Fix Released
Medium
Unassigned

Bug Description

When using a clouds.yaml config, Python will convert things in yaml to matching python objects. An unquoted number becomes an int.

However, osc-lib does not attempt to stringify the things it gets from config, but assumes it'll be a string.

Traceback (most recent call last):
  File "/Users/jkeating/.virtualenvs/osc/lib/python2.7/site-packages/osc_lib/shell.py", line 135, in run
    ret_val = super(OpenStackShell, self).run(argv)
  File "/Users/jkeating/.virtualenvs/osc/lib/python2.7/site-packages/cliff/app.py", line 250, in run
    self.initialize_app(remainder)
  File "/Users/jkeating/.virtualenvs/osc/lib/python2.7/site-packages/openstackclient/shell.py", line 135, in initialize_app
    super(OpenStackShell, self).initialize_app(argv)
  File "/Users/jkeating/.virtualenvs/osc/lib/python2.7/site-packages/osc_lib/shell.py", line 395, in initialize_app
    argparse=self.options,
  File "/Users/jkeating/.virtualenvs/osc/lib/python2.7/site-packages/osc_lib/cli/client_config.py", line 168, in get_one_cloud
    **kwargs
  File "/Users/jkeating/.virtualenvs/osc/lib/python2.7/site-packages/os_client_config/config.py", line 1092, in get_one_cloud
    config = self.auth_config_hook(config)
  File "/Users/jkeating/.virtualenvs/osc/lib/python2.7/site-packages/osc_lib/cli/client_config.py", line 147, in auth_config_hook
    config = self._auth_v2_ignore_v3(config)
  File "/Users/jkeating/.virtualenvs/osc/lib/python2.7/site-packages/osc_lib/cli/client_config.py", line 85, in _auth_v2_ignore_v3
    if (config.get('identity_api_version', '').startswith('2') and
AttributeError: 'int' object has no attribute 'starts with'

Quoting the number in yaml works around this, but obviously the code should ensure a string.

Revision history for this message
Steve Martinelli (stevemar) wrote :
Changed in python-openstackclient:
importance: Undecided → Medium
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to osc-lib (master)

Reviewed: https://review.openstack.org/388832
Committed: https://git.openstack.org/cgit/openstack/osc-lib/commit/?id=fe8b2a798d08df5b6dc5b00c9866932edf0f9a67
Submitter: Jenkins
Branch: master

commit fe8b2a798d08df5b6dc5b00c9866932edf0f9a67
Author: Jesse Keating <email address hidden>
Date: Wed Oct 19 10:50:53 2016 -0700

    Avoid string actions on non-string objects

    When config is coming from a clouds.yaml file, Python's yaml parser may
    turn the version into an int if it is not quoted in the yaml. Ensure
    that we set the value to a string before interacting with it.

    Also fix a possible string action on a None object.

    Change-Id: Ibf02a85d89c95ba76688b3f5c417f861173008d5
    Closes-Bug: #1634986

Changed in python-openstackclient:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/osc-lib 1.3.0

This issue was fixed in the openstack/osc-lib 1.3.0 release.

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.