Univention Bugzilla – Bug 52784
Kelvin API fails listing users, when exam users are present
Last modified: 2021-02-23 09:30:02 CET
When retrieving the list of school users (GET /ucsschool/kelvin/v1/users/) and an exam user exists: ==> /var/log/univention/ucsschool-kelvin-rest-api/http.log <== 2021-02-12 09:59:26 INFO 172.17.42.1:41064 - "GET /ucsschool/kelvin/v1/users/ HTTP/1.1" 500 2021-02-12 09:59:26 ERROR Exception in ASGI application Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 394, in run_asgi result = await app(self.scope, self.receive, self.send) File "/usr/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__ return await self.app(scope, receive, send) File "/usr/lib/python3.8/site-packages/fastapi/applications.py", line 140, in __call__ await super().__call__(scope, receive, send) File "/usr/lib/python3.8/site-packages/starlette/applications.py", line 134, in __call__ await self.error_middleware(scope, receive, send) File "/usr/lib/python3.8/site-packages/starlette/middleware/errors.py", line 178, in __call__ raise exc from None File "/usr/lib/python3.8/site-packages/starlette/middleware/errors.py", line 156, in __call__ await self.app(scope, receive, _send) File "/usr/lib/python3.8/site-packages/starlette/exceptions.py", line 73, in __call__ raise exc from None File "/usr/lib/python3.8/site-packages/starlette/exceptions.py", line 62, in __call__ await self.app(scope, receive, sender) File "/usr/lib/python3.8/site-packages/starlette/routing.py", line 590, in __call__ await route(scope, receive, send) File "/usr/lib/python3.8/site-packages/starlette/routing.py", line 208, in __call__ await self.app(scope, receive, send) File "/usr/lib/python3.8/site-packages/starlette/routing.py", line 41, in app response = await func(request) File "/usr/lib/python3.8/site-packages/fastapi/routing.py", line 127, in app raw_response = await dependant.call(**values) File "/kelvin/kelvin-api/ucsschool/kelvin/routers/user.py", line 608, in search obj = await UserModel.from_lib_model(user, request, udm) File "/kelvin/kelvin-api/ucsschool/kelvin/routers/base.py", line 120, in from_lib_model kwargs = await cls._from_lib_model_kwargs(obj, request, udm) File "/kelvin/kelvin-api/ucsschool/kelvin/routers/user.py", line 331, in _from_lib_model_kwargs {SchoolUserRole.from_lib_role(role) for role in obj.ucsschool_roles} File "/kelvin/kelvin-api/ucsschool/kelvin/routers/user.py", line 331, in <setcomp> {SchoolUserRole.from_lib_role(role) for role in obj.ucsschool_roles} File "/kelvin/kelvin-api/ucsschool/kelvin/routers/role.py", line 69, in from_lib_role return cls(lib_role) File "/usr/lib/python3.8/enum.py", line 309, in __call__ return cls.__new__(cls, value) File "/usr/lib/python3.8/enum.py", line 600, in __new__ raise exc File "/usr/lib/python3.8/enum.py", line 584, in __new__ result = cls._missing_(value) File "/usr/lib/python3.8/enum.py", line 613, in _missing_ raise ValueError("%r is not a valid %s" % (value, cls.__name__)) ValueError: 'exam_user:school:DEMOSCHOOL' is not a valid SchoolUserRole
Exam users are now handled as students. There should be another bug to(optionally?) ignore them. [feature/kelvin 441b5fead] Bug #52784: handle exam users as students The code has already been cherry-picked into the branch twenzel/52309_validation 4b5385a30.
QA → All OK → VERIFY Code → Looks good curl -X GET "http://$host/ucsschool/kelvin/v1/users/?school=DEMOSCHOOL" -H "accept: application/json" -H "Authorization: Bearer $token" → doesn't log errors in http.log not listing exam users by default is implemented in https://forge.univention.org/bugzilla/show_bug.cgi?id=52787
A Kelvin API app with the changes in this bug has been published.