Bug 56271 - UDM REST API Client Can't save nested lists
UDM REST API Client Can't save nested lists
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM - REST API
UCS 5.0
Other Linux
: P5 normal (vote)
: UCS 5.0-4-errata
Assigned To: Johannes Lohmer
Florian Best
https://git.knut.univention.de/univen...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2023-07-06 14:30 CEST by Johannes Lohmer
Modified: 2023-07-19 17:15 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 4: Minor Usability: Impairs usability in secondary scenarios
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 5: Blocking further progress on the daily work
User Pain: 0.229
Enterprise Customer affected?: Yes
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 Johannes Lohmer univentionstaff 2023-07-06 14:30:00 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.
Comment 1 Johannes Lohmer univentionstaff 2023-07-06 15:12:12 CEST
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}"}]}
}
Comment 2 Florian Best univentionstaff 2023-07-18 11:20:49 CEST
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
Comment 3 Florian Best univentionstaff 2023-07-18 11:21:27 CEST
OK: nested lists no consider the subsyntaxes
OK: copying of _links
OK: YAML