TypeError raised when trying to get domain properties in AccessInfo object

Bug #1477327 reported by Paulo Ewerton
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
keystoneauth
Fix Released
Low
Boris Bobrov

Bug Description

Attempts to access domain_name or domain_id in https://github.com/openstack/keystoneauth/blob/master/keystoneauth1/access.py raises TypeError exception.

To exercise this bug, add this test case (or similar access attempt to properties domain_id or domain_name) http://paste.openstack.org/show/401391/ to keystoneauth1/tests/unit/auth/test_access.py and run tox.

Some log details, when trying to reproduce the steps above:

======================================================================
FAIL: keystoneauth1.tests.unit.auth.test_access.AccessInfoPluginTests.test_domain_properties
tags: worker-3
----------------------------------------------------------------------
pythonlogging:'': {{{
Parsed 2015-07-22T21:56:30.876930 into {'separator': 'T', 'tz_minute': None, 'monthdash': '07', 'tz_sign': None, 'tz_hour': None, 'hour': '21', 'year': '2015', 'day': None, 'timezone': None, 'second': '30', 'daydash': '22', 'second_fraction': '876930', 'minute': '56', 'month': None} with default timezone <iso8601.iso8601.Utc object at 0x7f74e54a7090>
Got '2015' for 'year' with default None
Got '07' for 'monthdash' with default 1
Got 7 for 'month' with default 7
Got '22' for 'daydash' with default 1
Got 22 for 'day' with default 22
Got '21' for 'hour' with default None
Got '56' for 'minute' with default None
Got '30' for 'second' with default None
}}}

Traceback (most recent call last):======================================================================
FAIL: keystoneauth1.tests.unit.auth.test_access.AccessInfoPluginTests.test_domain_properties
tags: worker-3
----------------------------------------------------------------------
pythonlogging:'': {{{
Parsed 2015-07-22T21:56:30.876930 into {'separator': 'T', 'tz_minute': None, 'monthdash': '07', 'tz_sign': None, 'tz_hour': None, 'hour': '21', 'year': '2015', 'day': None, 'timezone': None, 'second': '30', 'daydash': '22', 'second_fraction': '876930', 'minute': '56', 'month': None} with default timezone <iso8601.iso8601.Utc object at 0x7f74e54a7090>
Got '2015' for 'year' with default None
Got '07' for 'monthdash' with default 1
Got 7 for 'month' with default 7
Got '22' for 'daydash' with default 1
Got 22 for 'day' with default 22
Got '21' for 'hour' with default None
Got '56' for 'minute' with default None
Got '30' for 'second' with default None
}}}

Traceback (most recent call last):
  File "keystoneauth1/tests/unit/auth/test_access.py", line 65, in test_domain_properties
    print auth_ref.domain_ids
  File "keystoneauth1/access.py", line 49, in inner
    return f(self)
  File "keystoneauth1/access.py", line 612, in domain_id
    return self._domain['id']
TypeError: 'NoneType' object has no attribute '__getitem__'
Ran 207 tests in 0.723s (+0.278s)
FAILED (id=2, failures=1)
error: testr failed (1)

Revision history for this message
David Stanek (dstanek) wrote :

We had a short discussion about this in IRC today. The issue is that since ``_domain`` is decorated as a ``missingproperty`` any KeyErrors will actually be returned as a None. There are other properties like ``domain_id`` and ``domain_name`` that don't check for a None before accessing the ``_domain`` as a dictionary.

I'm thinking these other properties should check for a None and raise a smarter error saying that a domain was not found.

Changed in keystoneauth:
status: New → Confirmed
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystoneauth (master)

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

Changed in keystoneauth:
assignee: nobody → Boris Bobrov (bbobrov)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

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

Reviewed: https://review.openstack.org/205094
Committed: https://git.openstack.org/cgit/openstack/keystoneauth/commit/?id=09503fcc72b339e0a9fd8e929ce4e71bc47b8cfe
Submitter: Jenkins
Branch: master

commit 09503fcc72b339e0a9fd8e929ce4e71bc47b8cfe
Author: Boris Bobrov <email address hidden>
Date: Thu Jul 23 17:52:22 2015 +0300

    Expose bug in AccessToken

    Some properties in AccessToken have either wrong decorators or don't
    catch necessary exceptions.

    Add testcases that expose bugs in these properties.

    Change-Id: I5897f31786317dae6534c89fa41a38f6cb15a168
    Partial-Bug: 1477327

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/205209
Committed: https://git.openstack.org/cgit/openstack/keystoneauth/commit/?id=c7492e771581a9f4a2618ea514561a80db60aa06
Submitter: Jenkins
Branch: master

commit c7492e771581a9f4a2618ea514561a80db60aa06
Author: Boris Bobrov <email address hidden>
Date: Thu Jul 23 21:10:54 2015 +0300

    Fix decorators of properties in AccessToken

    Change-Id: I45ae75e866696299696ab5b5fcfb0e38ff1ca34b
    Closes-Bug: 1477327

Changed in keystoneauth:
status: In Progress → Fix Committed
Changed in keystoneauth:
milestone: none → 0.4.0
status: Fix Committed → Fix Released
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.