Univention Bugzilla – Bug 56271
UDM REST API Client Can't save nested lists
Last modified: 2023-07-19 17:15:33 CEST
The `link` property of the `portal/entry` objects is a nested list: obj = entry.get('cn=univentionwebsite,cn=entry,cn=portals,cn=univention,dc=ucs,dc=test') 'link': [['en_US', 'https://www.univention.com'], ['de_DE', 'https://www.univention.de']],  But the python client can't save properties that are nested lists: >>> obj = entry.get('cn=univentionwebsite,cn=entry,cn=portals,cn=univention,dc=ucs,dc=test') >>> obj.save() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/jlohmer/git/ucs/management/univention-directory-manager-rest/src/univention/admin/rest/client/__init__.py", line 631, in save return self._modify(reload) File "/home/jlohmer/git/ucs/management/univention-directory-manager-rest/src/univention/admin/rest/client/__init__.py", line 653, in _modify response = self.client.make_request('PUT', self.uri, data=self.representation, allow_redirects=False, **headers) # type: ignore # <https://github.com/python/mypy/issues/10008> File "/home/jlohmer/git/ucs/management/univention-directory-manager-rest/src/univention/admin/rest/client/__init__.py", line 196, in make_request return doit() File "/home/jlohmer/git/ucs/management/univention-directory-manager-rest/src/univention/admin/rest/client/__init__.py", line 191, in doit data = self.eval_response(response, expect_json=expect_json) File "/home/jlohmer/git/ucs/management/univention-directory-manager-rest/src/univention/admin/rest/client/__init__.py", line 233, in eval_response raise cls(response.status_code, msg, response, error_details=error_details) univention.admin.rest.client.UnprocessableEntity: PUT http://10.207.199.64/univention/udm/portals/entry/cn%3Duniventionwebsite%2Ccn%3Dentry%2Ccn%3Dportals%2Ccn%3Dunivention%2Cdc%3Ducs%2Cdc%3Dtest: 422 1 error(s) occurred: Request argument "link" The property link has an invalid value: too many arguments. This is obviously a bug in the python client because it should be able to save objects that are added by the portal join-script. Meaning they are in every UCS system.
Since the Bug is also reproducible with Curl. I now strongly suspect that it's actually a bug in the UDM REST API Server! curl -X GET -H "Accept: application/json" --dump-header website.headers "http://${USER}:${PASSWORD}@10.207.199.64/univention/udm/portals/entry/cn=univentionwebsite,cn=entry,cn=portals,cn=univention,dc=ucs,dc=test" | python3 -m json.tool > univentionwebsite.json curl -X PUT -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H 'If-Match: "4e69c78e7a137f4f48883eaa8fd4d4544c3049da"' \ "http://${USER}:${PASSWORD}@10.207.199.64/univention/udm/portals/entry/cn=univentionwebsite,cn=entry,cn=portals,cn=univention,dc=ucs,dc=test" \ --data @univentionwebsite.json {"error": { "code": 422, "title": "Unprocessable Entity", "message": "1 error(s) occurred:\nRequest argument \"link\" The property link has an invalid value: too many arguments.\n, "error": {"link": "The property link has an invalid value: too many arguments."}}, "_embedded": {"udm:error": [{"location": ["body", "properties", "link"], "message": "The property link has an invalid value: too many arguments.", "type": "value_error"}]}, "_links": {"self": [{"title": "HTTP-Error 422: Unprocessable Entity", "href": "http://10.207.199.64/univention/udm/portals/entry/cn%3Duniventionwebsite%2Ccn%3Dentry%2Ccn%3Dportals%2Ccn%3Dunivention%2Cdc%3Ducs%2Cdc%3Dtest"}], "curies": [{"name": "udm", "templated": true, "href": "http://10.207.199.64/univention/udm/relation/{rel}"}]} }
univention-directory-manager-rest.yaml c0dcda134b9e | Bug #56271: add advisory and debian/changelog univention-directory-manager-rest (10.0.6-9) 01c2440d2f16 | fix(udm-rest): Avoid overwriting the module relations c0dcda134b9e | Bug #56271: add advisory and debian/changelog univention-directory-manager-modules.yaml c0dcda134b9e | Bug #56271: add advisory and debian/changelog univention-directory-manager-modules (15.0.24-12) 135bc82b44d0 | fix(udm): handle type_class == None univention-directory-manager-modules (15.0.24-11) 133b3f4f567c | fix(udm): assign subsyntaxes to TypeHint instances c0dcda134b9e | Bug #56271: add advisory and debian/changelog
OK: nested lists no consider the subsyntaxes OK: copying of _links OK: YAML
<https://errata.software-univention.de/#/?erratum=5.0x744> <https://errata.software-univention.de/#/?erratum=5.0x745>