Univention Bugzilla – Bug 52927
ValueError in Kelvin 1.4.0 in validator initialization code
Last modified: 2021-03-18 11:58:14 CET
As the UCRV ucsschool/validation/logging/backupcount is now copied from the host into the Docker container, it can will be set to an empty string when unset in the host. ----------------------------------------------------------------------------- /kelvin # ucr dump | grep validation ucsschool/validation/logging/backupcount: ----------------------------------------------------------------------------- /kelvin # python3 Python 3.8.8 (default, Mar 15 2021, 13:12:20) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from ucsschool.lib.models.validator import validate Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/kelvin/ucs-school-lib/modules/ucsschool/lib/models/__init__.py", line 34, in <module> from .computer import * # noqa: F401, F403 File "/kelvin/ucs-school-lib/modules/ucsschool/lib/models/computer.py", line 50, in <module> from .base import MultipleObjectsError, RoleSupportMixin, SuperOrdinateType, UCSSchoolHelperAbstractClass File "/kelvin/ucs-school-lib/modules/ucsschool/lib/models/base.py", line 51, in <module> from .validator import validate File "/kelvin/ucs-school-lib/modules/ucsschool/lib/models/validator.py", line 69, in <module> backup_count = int(ucr.get("ucsschool/validation/logging/backupcount", 60)) ValueError: invalid literal for int() with base 10: '' ----------------------------------------------------------------------------- Handle an empty value for the UCRV ucsschool/validation/logging/backupcount.
I just noticed that the above code with int() isn't the most common in the git repo. But without conversion to int the code would just crash in the Python logging library code. [feature/kelvin ecb70fb38] Bug #52927: fix ValueError for empty UCRV
*** Bug 52928 has been marked as a duplicate of this bug. ***
If the ucr-v ucsschool/validation/logging/backupcount is not set, this will stil raise an error. /kelvin/ucs-school-lib # python3 Python 3.8.8 (default, Mar 15 2021, 13:12:20) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from ucsschool.lib.models.validator import validate Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/kelvin/ucs-school-lib/modules/ucsschool/lib/models/__init__.py", line 37, in <module> from .school import * File "/kelvin/ucs-school-lib/modules/ucsschool/lib/models/school.py", line 63, in <module> from .base import RoleSupportMixin, UCSSchoolHelperAbstractClass File "/kelvin/ucs-school-lib/modules/ucsschool/lib/models/base.py", line 67, in <module> from .validator import validate File "/kelvin/ucs-school-lib/modules/ucsschool/lib/models/validator.py", line 65, in <module> backup_count = int(ucr.get("ucsschool/validation/logging/backupcount").strip() or 60) AttributeError: 'NoneType' object has no attribute 'strip' I already have a fix (because I did QA for 52928 first). In 4.4 the code is also wrong. [twenzel/4.4/52930_attribute_error] b949561c5 Bug #52930: fix attribute error [twenzel/kelvin/52930_attribute_error] 89a0c3044 Bug 52930: fix attribute error
*** Bug 52930 has been marked as a duplicate of this bug. ***
The code change does not work for an unset UCRV. The UCR behavior seems erratic in Kelvin, will investigate separately. Fixed for now: [feature/kelvin 45a197f6d] Bug #52927: fix AttributeError for unset UCRV
I made the same change in the 4.4 branch. It is not strictly necessary there, but doesn't hurt either and will make syncing the branches easier. [4.4 0f6980b89] Bug #52927: sync code to feature/kelvin
QA → All OK → Verify Thanks!