Bug 50485 - UDM REST Client: Minor issues
UDM REST Client: Minor issues
Status: RESOLVED WORKSFORME
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: UMC maintainers
UMC maintainers
:
Depends on: 51685
Blocks:
  Show dependency treegraph
 
Reported: 2019-11-13 09:12 CET by Dirk Wiesenthal
Modified: 2021-09-10 09:17 CEST (History)
1 user (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
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:
best: Patch_Available+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Wiesenthal univentionstaff 2019-11-13 09:12:42 CET
Some unrelated issues I found when using the new rest client "univention.admin.rest.client". I could open one bug per issue, but maybe this is easier:

1) I need the ldap/base from the server. I found no trivial way of doing this, although I think it is a common task. udm.get_ldap_base() would be nice to have.

2) Object.uri may give a traceback, presumably when the object does not yet exist
>>> user = udm.get('users/user').new()
>>> user.uri
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "univention/admin/rest/client/__init__.py", line 447, in uri
    uri = self.client.get_relation(self.hal, 'self')
  File "univention/admin/rest/client/__init__.py", line 225, in get_relation
    return next(self.get_relations(entry, relation, name, template))
StopIteration

3) The method _reload_from_response uses a variable that is just not defined: "reload". Funnily enough, this still works in Python 2.7 because reload is a builtin, making "if reload" always True. But in Python 3 this gives a traceback.

4) If a URI is used that is not a UDM REST API's endpoint, I saw a traceback:

univention.admin.rest.client.UDM.http('http://localhost/univention/udm/', 'Administrator', 'univention').get('users/user')
works as expected. Now if I give a wrong uri, it should not work. But instead of a readable error message, I get this:

univention.admin.rest.client.UDM.http('http://localhost/', 'Administrator', 'univention').get('users/user')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "univention/admin/rest/client/__init__.py", line 288, in get
    for module in self.modules(name):
  File "univention/admin/rest/client/__init__.py", line 271, in modules
    for module in self.client.resolve_relations(self.entry, 'udm:object-modules'):
  File "univention/admin/rest/client/__init__.py", line 228, in resolve_relations
    embedded = entry.get('_embedded', {})
AttributeError: 'unicode' object has no attribute 'get'

"entry" here is the HTML from /univention/portal/index.html

5) During code inspection, I found that "make_request" has a loop built in that retries during ServiceUnavailable. But the way it is implemented I do not think this works. The last line in the except clause does a "return doit()" again. I guess this needs to be removed?
Comment 1 Florian Best univentionstaff 2019-11-13 09:53:15 CET
Thanks. All points adressed in git:fbest/50485-rest-client-errors.
Comment 2 Florian Best univentionstaff 2021-09-10 09:17:49 CEST
This was already fixed during Python 3 Migration in Bug #51685.