Bug 56146 - Wrong policies written back with Simple UDM API version 3
Wrong policies written back with Simple UDM API version 3
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 5.0
Other Linux
: P5 normal (vote)
: UCS 5.0-4
Assigned To: Florian Best
Dirk Wiesenthal
:
Depends on: 50167
Blocks:
  Show dependency treegraph
 
Reported: 2023-06-13 18:08 CEST by Florian Best
Modified: 2023-06-21 09:24 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 7: Crash: Bug causes crash or data loss
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.120
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
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 2023-06-13 18:08:19 CEST
Version 3 of Simple UDM API introduced policies in UDM REST API like representations.
The decoding part works fine, but encoding it back when saving is broken and stores the UDM policy module names instead of the DNs.

Another problem is that the ListOfListOflTextToDictPropertyEncoder returns a list instead of a dict in case the values provided are empty. It should always return a dict.

+++ This bug was initially created as a clone of Bug #50167 +++
Comment 1 Florian Best univentionstaff 2023-06-13 18:14:30 CEST
univention-directory-manager-modules (15.0.23-1)
c86b8405e700 | fix(simple-udm): fix saving policies in version >= 3
0231ce7e64b2 | fix(simple-udm): ListOfListOflTextToDictPropertyEncoder should always return a dict
Comment 2 Florian Best univentionstaff 2023-06-14 20:40:25 CEST
univention-directory-manager-modules (15.0.24-1)
acd97b360e5a | Bug #56146: fix settting empty policy

fixed:

https://jenkins2022.knut.univention.de/job/UCS-5.0/job/UCS-5.0-4/job/AutotestJoin/SambaVersion=no-samba,Systemrolle=master-part-II/ws/test/ucs-test.log
Traceback (most recent call last):
  File "/usr/share/ucs-test/86_selenium/17_self_service_registration.py", line 43, in activate_self_registration
    yield ucr
  File "/usr/lib/python3/dist-packages/univention/testing/ucr.py", line 121, in __exit__
    self.revert_to_original_registry()
  File "/usr/lib/python3/dist-packages/univention/testing/ucr.py", line 101, in revert_to_original_registry
    self.handler_unset(list(keylist), {option: True})
  File "/usr/lib/python3/dist-packages/univention/testing/ucr.py", line 74, in handler_unset
    return univention.config_registry.handler_unset(*args)
  File "/usr/lib/python3/dist-packages/univention/config_registry/frontend.py", line 232, in handler_unset
    _run_changed(ucr, changed, 'W: %s is still set in scope "%s"')
  File "/usr/lib/python3/dist-packages/univention/config_registry/frontend.py", line 275, in _run_changed
    handlers(list(visible), (ucr, visible))
  File "/usr/lib/python3/dist-packages/univention/config_registry/handler.py", line 1101, in __call__
    handler(arg)
  File "/usr/lib/python3/dist-packages/univention/config_registry/handler.py", line 636, in __call__
    run_module(self.module, 'handler', ucr, changed)
  File "/usr/lib/python3/dist-packages/univention/config_registry/handler.py", line 220, in run_module
    f(ucr, changes)
  File "/etc/univention/templates/modules/self-service-links.py", line 59, in handler
    obj.save()
  File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 176, in save
    self._copy_to_udm_obj()
  File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 343, in _copy_to_udm_obj
    self._orig_udm_object.policies = functools.reduce(lambda x, y: x + y, self.policies.values())
TypeError: reduce() of empty sequence with no initial value
Comment 3 Dirk Wiesenthal univentionstaff 2023-06-19 05:36:44 CEST
OK: Self service joinscript works again with version(3)
OK: Code review
Comment 4 Philipp Hahn univentionstaff 2023-06-21 09:24:42 CEST
UCS 5.0-4 has been released:
 https://docs.software-univention.de/release-notes/5.0-4/en/

If this error occurs again, please use the 'Clone This Bug' option.