Problem: Kelvin API throws Traceback


Using the Kelvin API ends with tracebacks like this:

2021-02-24 10:15:29 INFO  Going to create ImportStudent(name='Testuser1', school='DEMOSCHOOL', dn='uid=Testuser1,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=supportschool,dc=univention,dc=intranet', old_dn=None) with {'$dn$': 'uid=Testuser1,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=supportschool,dc=univention,dc=de', 'objectType': 'users/user', 'school': 'DEMOSCHOOL', 'name': 'Testuser1', 'schools': ['DEMOSCHOOL'], 'firstname': 'Hans', 'lastname': 'Wurst', 'birthday': None, 'email': '', 'password': '********', 'disabled': False, 'school_classes': {'DEMOSCHOOL': ['10OS']}, 'ucsschool_roles': ['student:school:DEMOSCHOOL'], 'source_uid': 'Kelvin', 'record_uid': '29', 'display_name': 'Hans Wurst', 'type_name': 'Student', 'type': 'importStudent', 'action': 'A', 'entry_count': 0, 'udm_properties': {'overridePWHistory': True, 'overridePWLength': True}, 'input_data': [], 'old_user': None, 'in_hook': False, 'roles': ['student']}...
2021-02-24 10:15:29 INFO - "POST /ucsschool/kelvin/v1/users/ HTTP/1.1" 500
2021-02-24 10:15:29 ERROR Exception in ASGI application
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/uvicorn/protocols/http/", line 394, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/usr/lib/python3.8/site-packages/uvicorn/middleware/", line 45, in __call__
    return await, receive, send)
  File "/usr/lib/python3.8/site-packages/fastapi/", line 140, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/lib/python3.8/site-packages/starlette/", line 134, in __call__
    await self.error_middleware(scope, receive, send)
  File "/usr/lib/python3.8/site-packages/starlette/middleware/", line 178, in __call__
    raise exc from None
  File "/usr/lib/python3.8/site-packages/starlette/middleware/", line 156, in __call__
    await, receive, _send)
  File "/usr/lib/python3.8/site-packages/starlette/", line 73, in __call__
    raise exc from None
  File "/usr/lib/python3.8/site-packages/starlette/", line 62, in __call__
    await, receive, sender)
  File "/usr/lib/python3.8/site-packages/starlette/", line 590, in __call__
    await route(scope, receive, send)
  File "/usr/lib/python3.8/site-packages/starlette/", line 208, in __call__
    await, receive, send)
  File "/usr/lib/python3.8/site-packages/starlette/", line 41, in app
    response = await func(request)
  File "/usr/lib/python3.8/site-packages/fastapi/", line 127, in app
    raw_response = await**values)
  File "/kelvin/kelvin-api/ucsschool/kelvin/routers/", line 715, in create
    res = await user.create(udm)
  File "/kelvin/ucs-school-import/modules/ucsschool/importer/models/", line 324, in create
    res = await super(ImportUser, self).create(lo, validate)
  File "/kelvin/ucs-school-lib/modules/ucsschool/lib/models/", line 418, in create
    await self.call_hooks(lo, 'pre', 'create')
  File "/kelvin/ucs-school-import/modules/ucsschool/importer/models/", line 223, in call_hooks
    await func(self)
  File "/var/lib/ucs-school-import/kelvin-hooks/", line 45, in pre_create
    if in ucr.get('univention/oxcontext/schools'):
TypeError: argument of type 'NoneType' is not iterable

Important is the penultimate line:
if in ucr.get(‘univention/oxcontext/schools’):


Get the Value of the UCR on the master:

root@ucs-master:~# ucr get univention/oxcontext/schools

Open a shell in the kelvin-api docker container and set the UCR in there:

root@ucs-master:~# univention-app shell ucsschool-kelvin-rest-api
/kelvin # ucr set univention/oxcontext/schools='DEMOSCHOOL DEMOSCHOOL2'
Create univention/oxcontext/schools
E: your request could not be fulfilled
try `univention-config-registry --help` for more information
/kelvin # ucr get univention/oxcontext/schools
/kelvin # exit

Verify that the UCR is set and ignore the error message.

Root Cause

Kelvin API runs in a docker. So if you customized your import you probably use UCR variables that are actual not syncronized to the docker (Check Bug 52934)
These variables need to be set manually.