Bug 52784 - Kelvin API fails listing users, when exam users are present
Kelvin API fails listing users, when exam users are present
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: HTTP-API (Kelvin)
UCS@school 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: Daniel Tröder
Tobias Wenzel
:
Depends on: 52783 52787
Blocks: 52309
  Show dependency treegraph
 
Reported: 2021-02-12 11:42 CET by Daniel Tröder
Modified: 2021-02-23 09:30 CET (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
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:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2021-02-12 11:42:23 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
Comment 1 Daniel Tröder univentionstaff 2021-02-12 11:47:54 CET
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.
Comment 2 Tobias Wenzel univentionstaff 2021-02-15 13:34:12 CET
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
Comment 3 Daniel Tröder univentionstaff 2021-02-23 09:30:02 CET
A Kelvin API app with the changes in this bug has been published.