'Unauthorized' exception is not handled properly

Bug #1755851 reported by Vadym Markov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-pankoclient
Fix Released
Undecided
Unassigned

Bug Description

Example on fresh devstack:

$ openstack --os-cloud devstack event trait description security_group_rule.create.end

http://192.168.122.233:8977 "GET /v2/event_types/security_group_rule.create.end/traits/ HTTP/1.1" 401 455
RESP: [401] Date: Wed, 14 Mar 2018 15:54:35 GMT Server: Apache/2.4.18 (Ubuntu) x-openstack-request-id: req-0086f261-0f76-4810-be1b-9d4727efdf00 WWW-Authenticate: Keystone uri='http://192.168.122.233/identity' Content-Length: 455 Connection: close Content-Type: application/json
RESP BODY: {"error_message": "<html>\n <head>\n <title>401 Unauthorized</title>\n </head>\n <body>\n <h1>401 Unauthorized</h1>\n This server could not verify that you are authorized to access the document you requested. Either you supplied the wrong credentials (e.g., bad password), or your browser does not understand how to supply the credentials required.<br /><br />\nNot Authorized to access project aa4dcc3bc5ae4729bda30840e984edc6\n\n\n </body>\n</html>"}

'unicode' object has no attribute 'get'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/cliff/app.py", line 400, in run_subcommand
    result = cmd.run(parsed_args)
  File "/usr/local/lib/python2.7/dist-packages/osc_lib/command/command.py", line 41, in run
    return super(Command, self).run(parsed_args)
  File "/usr/local/lib/python2.7/dist-packages/cliff/display.py", line 116, in run
    column_names, data = self.take_action(parsed_args)
  File "/opt/stack/python-pankoclient/pankoclient/v2/events_cli.py", line 151, in take_action
    event_traits = ac.event_trait_description.list(parsed_args.type_name)
  File "/opt/stack/python-pankoclient/pankoclient/v2/events.py", line 89, in list
    return self._list(url)
  File "/opt/stack/python-pankoclient/pankoclient/common/base.py", line 57, in _list
    resp, body = self.api.get(url, headers=headers)
  File "/usr/local/lib/python2.7/dist-packages/keystoneauth1/adapter.py", line 304, in get
    return self.request(url, 'GET', **kwargs)
  File "/opt/stack/python-pankoclient/pankoclient/client.py", line 39, in request
    raise exceptions.from_response(resp, url, method)
  File "/opt/stack/python-pankoclient/pankoclient/exceptions.py", line 175, in from_response
    desc = body.get('error_message', {}).get('faultstring')
AttributeError: 'unicode' object has no attribute 'get'
clean_up EventTraitDescription: 'unicode' object has no attribute 'get'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/osc_lib/shell.py", line 134, in run
    ret_val = super(OpenStackShell, self).run(argv)
  File "/usr/local/lib/python2.7/dist-packages/cliff/app.py", line 279, in run
    result = self.run_subcommand(remainder)
  File "/usr/local/lib/python2.7/dist-packages/osc_lib/shell.py", line 169, in run_subcommand
    ret_value = super(OpenStackShell, self).run_subcommand(argv)
  File "/usr/local/lib/python2.7/dist-packages/cliff/app.py", line 400, in run_subcommand
    result = cmd.run(parsed_args)
  File "/usr/local/lib/python2.7/dist-packages/osc_lib/command/command.py", line 41, in run
    return super(Command, self).run(parsed_args)
  File "/usr/local/lib/python2.7/dist-packages/cliff/display.py", line 116, in run
    column_names, data = self.take_action(parsed_args)
  File "/opt/stack/python-pankoclient/pankoclient/v2/events_cli.py", line 151, in take_action
    event_traits = ac.event_trait_description.list(parsed_args.type_name)
  File "/opt/stack/python-pankoclient/pankoclient/v2/events.py", line 89, in list
    return self._list(url)
  File "/opt/stack/python-pankoclient/pankoclient/common/base.py", line 57, in _list
    resp, body = self.api.get(url, headers=headers)
  File "/usr/local/lib/python2.7/dist-packages/keystoneauth1/adapter.py", line 304, in get
    return self.request(url, 'GET', **kwargs)
  File "/opt/stack/python-pankoclient/pankoclient/client.py", line 39, in request
    raise exceptions.from_response(resp, url, method)
  File "/opt/stack/python-pankoclient/pankoclient/exceptions.py", line 175, in from_response
    desc = body.get('error_message', {}).get('faultstring')
AttributeError: 'unicode' object has no attribute 'get'

END return value: 1

The reason seems to be the 401 response from Apache has the 'error_message' as a string, not as a dict with 'faultstring' key.

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

Reviewed: https://review.openstack.org/552981
Committed: https://git.openstack.org/cgit/openstack/python-pankoclient/commit/?id=8fc3a19e1e998c34ffe9be921a5ba3f3b622addd
Submitter: Zuul
Branch: master

commit 8fc3a19e1e998c34ffe9be921a5ba3f3b622addd
Author: vmarkov <email address hidden>
Date: Wed Mar 14 19:01:46 2018 +0200

    Handle strings as response error_message

    Change-Id: I9643303973edd992066ff013a9cec21be689ae84
    Closes-Bug: #1755851

Changed in python-pankoclient:
status: New → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-pankoclient (stable/queens)

Fix proposed to branch: stable/queens
Review: https://review.openstack.org/575392

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-pankoclient (stable/queens)

Reviewed: https://review.openstack.org/575392
Committed: https://git.openstack.org/cgit/openstack/python-pankoclient/commit/?id=748f9312f4f139baf7dba93271e1b5af1acbcc4b
Submitter: Zuul
Branch: stable/queens

commit 748f9312f4f139baf7dba93271e1b5af1acbcc4b
Author: vmarkov <email address hidden>
Date: Wed Mar 14 19:01:46 2018 +0200

    Handle strings as response error_message

    Change-Id: I9643303973edd992066ff013a9cec21be689ae84
    Closes-Bug: #1755851
    (cherry picked from commit 8fc3a19e1e998c34ffe9be921a5ba3f3b622addd)

tags: added: in-stable-queens
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-pankoclient 0.4.1

This issue was fixed in the openstack/python-pankoclient 0.4.1 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-pankoclient 0.5.0

This issue was fixed in the openstack/python-pankoclient 0.5.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.