Univention Bugzilla – Bug 53571
computerroom/query: IndexError: list index out of range
Last modified: 2023-11-16 14:21:08 CET
Version: 5.0-0 errata44 Error: Interner Server-Fehler in "computerroom/query". Request: computerroom/query Traceback (most recent call last): File "%PY3%/univention/management/console/base.py", line 344, in __error_handling six.reraise(etype, exc, etraceback) File "%PY3%/six.py", line 693, in reraise raise value File "%PY3%/univention/management/console/base.py", line 247, in execute function.__func__(self, request, *args, **kwargs) File "%PY3%/ucsschool/lib/school_umc_ldap_connection.py", line 155, in wrapper_func return func(*args, **kwargs) File "%PY3%/univention/management/console/modules/computerroom/__init__.py", line 534, in query result = [computer.dict for computer in self._computerroom.values()] File "%PY3%/univention/management/console/modules/computerroom/__init__.py", line 534, in <listcomp> result = [computer.dict for computer in self._computerroom.values()] File "%PY3%/univention/management/console/modules/computerroom/room_management.py", line 527, in dict "mac": self.macAddress, File "%PY3%/univention/management/console/modules/computerroom/room_management.py", line 458, in macAddress return ip_addresses[0] IndexError: list index out of range Role: domaincontroller_master Errno: 287b3eea0c923797e514e90a9ace4bec
Happens when opening the computerroom module and the selected room contains an computer without an IP address.
(In reply to Florian Best from comment #1) > Happens when opening the computerroom module and the selected room contains > an computer without an IP address. s/IP/MAC/g
I could only partly reproduce this in 4.4 & 5.0. UCS: 4.4-8 errata1044 Installed: cups=2.2.1 samba4=4.10 squid=3.5 ucsschool=4.4 v9 this should be renamed, too: ip_addresses -> mac_addresses @property def macAddress(self): ip_addresses = self._computer.info.get("mac", [""]) return ip_addresses[0]
reported again: Version: 4.4-8 errata962 (Blumenthal) - UCS@school 4.4 v9 Error: Interner Server-Fehler in "computerroom/query". Request: computerroom/query Traceback (most recent call last): File "%PY2.7%/univention/management/console/base.py", line 359, in __error_handling six.reraise(etype, exc, etraceback) File "%PY2.7%/univention/management/console/base.py", line 262, in execute function.__func__(self, request, *args, **kwargs) File "%PY2.7%/ucsschool/lib/school_umc_ldap_connection.py", line 145, in wrapper_func return func(*args, **kwargs) File "%PY2.7%/univention/management/console/modules/computerroom/__init__.py", line 544, in query result = [computer.dict for computer in self._italc.values()] File "%PY2.7%/univention/management/console/modules/computerroom/room_management.py", line 1077, in dict "mac": self.macAddress, File "%PY2.7%/univention/management/console/modules/computerroom/room_management.py", line 1008, in macAddress return ip_addresses[0] IndexError: list index out of range Role: domaincontroller_master
Looks like this is the issue: >>> info = {"mac": []} >>> info.get("mac") [] >>> info.get("mac")[0] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range We did the following in macAddress: mac_addresses = self._computer.info.get("mac", [""]) return mac_addresses[0] For me it looks like if the mac is not set, we have self._computer.info.get("mac") == []. Possible solutions: @property def macAddress(self): mac_addresses = self._computer.info.get("mac", None) if mac_addresses is None: mac_addresses = [""] return mac_addresses[0] or, to have it similar to ip_addresses (,after self._mac_addresses = self._computer.info.get("mac", []) # type: List[str] in init): @property def macAddress(self): return self._mac_addresses[0] if self._mac_addresses else ""
florian suggested the following one liner: @property def macAddress(self): - ip_addresses = self._computer.info.get("mac", [""]) - return ip_addresses[0] + return (self._computer.info.get("mac") or [""])[0]
If a computer does not have an MAC address, it will still be displayed in the computer room and no error is thrown. With this issue, also https://forge.univention.org/bugzilla/show_bug.cgi?id=53624 is fixed. Merged & built with Package: ucs-school-umc-computerroom Version: 12.0.14 Branch: ucs_5.0-0 Scope: ucs-school-5.0 Package: ucs-test-ucsschool Version: 7.3.148 Branch: ucs_5.0-0 Scope: ucs-school-5.0
Errata updates for UCS@school 5.0 v4 have been released. https://docs.software-univention.de/ucsschool-changelog/5.0v4/en/changelog.html https://docs.software-univention.de/ucsschool-changelog/5.0v4/de/changelog.html If this error occurs again, please clone this bug.