Bug 45116 - uccsetup/info: fails with IndexError: list index out of range
uccsetup/info: fails with IndexError: list index out of range
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 4.2
Other Linux
: P5 normal (vote)
: UCS 4.2-1-errata
Assigned To: Florian Best
Johannes Keiser
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-08-01 16:31 CEST by Florian Best
Modified: 2017-08-02 14:34 CEST (History)
0 users

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 6: Setup Problem: Issue for the setup process
Who will be affected by this bug?: 1: Will affect a very few installed domains
How will those affected feel about the bug?: 3: A User would likely not purchase the product
User Pain: 0.103
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2017072721000223, 2017072721000358, 2017072921000283, 2017073021000155
Bug group (optional): Error handling, External feedback
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2017-08-01 16:31:30 CEST
Bug #37171 causes that when doing a lookup(required=True, unique=True)[0] a IndexError instead of a noObject exception is raised. Regressing behavior since Bug #30368.

Remark: - Server neu installiert
- Lizenz installiert
- UCC installiert -> Fehler :(

Version: 4.2-1 errata118 (Lesum)

Die Ausführung des Kommandos uccsetup/info ist fehlgeschlagen:

Traceback (most recent call last):
  File "%PY2.7%/univention/management/console/base.py", line 249, in execute
    function.__func__(self, request, *args, **kwargs)
  File "%PY2.7%/univention/management/console/modules/decorators.py", line 318, in _response
    result = _multi_response(self, request)
  File "%PY2.7%/univention/management/console/modules/decorators.py", line 192, in _response
    return function(self, request)
  File "%PY2.7%/univention/management/console/modules/decorators.py", line 440, in _response
    return list(function(self, iterator, *nones))
  File "%PY2.7%/univention/management/console/modules/decorators.py", line 286, in _fake_func
    yield function(self, *args)
  File "%PY2.7%/univention/management/console/modules/uccsetup/__init__.py", line 86, in info
    ucr_policy.update(util.get_ucr_policy_variables(ldap_connection))  # hack to access the method is_true()
  File "%PY2.7%/univention/management/console/modules/uccsetup/util.py", line 330, in get_ucr_policy_variables
    with _open_container_policy(container_dn, 'policies/registry', policy_dn, ldap_connection, read_only=True) as ucr_policy:
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "%PY2.7%/univention/management/console/modules/uccsetup/util.py", line 276, in _open_container_policy
    policy_obj = udm_objects.get(udm_modules.get(policy_type), None, ldap_connection, None, policy_dn)
  File "%PY2.7%/univention/admin/objects.py", line 84, in get
    obj = univention.admin.modules.lookup(module.module, co, lo, base=dn, superordinate=superordinate, scope='base', unique=True, required=True)[0]
IndexError: list index out of range
Comment 1 Florian Best univentionstaff 2017-08-01 16:37:41 CEST
>>> import univention.admin
>>> lo,po=univention.admin.uldap.getMachineConnection()
>>> univention.admin.modules.update()

E.g. expected behavior for a user:
>>> u = univention.admin.modules.get('users/user')
>>> u.lookup(None, lo, '', base='cn=DOESNOTEXISTS,dc=school,dc=local', required=True)[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.py", line 2846, in lookup
    for dn, attrs in lo.search(unicode(filter), base, scope, [], unique, required, timeout, sizelimit):
  File "/usr/lib/pymodules/python2.7/univention/admin/uldap.py", line 425, in search
    raise univention.admin.uexceptions.noObject(_err2str(msg))
univention.admin.uexceptions.noObject: No such object

Broken behavior for policies:

>>> p = univention.admin.modules.get('policies/registry')
>>> p.lookup(None, lo, '', base='cn=DOESNOTEXISTS,dc=school,dc=local', required=True)[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: list index out of range
Comment 2 Florian Best univentionstaff 2017-08-01 16:48:59 CEST
Fixed by catching ImportError:

univention-directory-manager-modules (12.0.18-8):
r81653 | Bug #45116: fix regression in univention.admin.objects.get()

univention-directory-manager-modules.yaml:
r81655 | YAML Bug #45116

QA: The following script should raise noObject instead of IndexError:

import univention.admin
lo,po=univention.admin.uldap.getMachineConnection()
univention.admin.modules.update()
p = univention.admin.modules.get('policies/registry')
print univention.admin.objects.get(p, None, lo, po, 'cn=foo,dc=school,dc=local')
Comment 3 Johannes Keiser univentionstaff 2017-08-01 18:13:16 CEST
OK univention.admin.objects.get fails with noObject error instead of IndexError if policies/registry object does not exist

YAML: OK
-> verified
Comment 4 Arvid Requate univentionstaff 2017-08-02 14:34:13 CEST
<http://errata.software-univention.de/ucs/4.2/121.html>