Problem: RuntimeError: Work group '...' does not exist, please create it first. During command line import


The command line import shows this message:

------ Mass import finished. ------
RuntimeError: Work group '...' does not exist, please create it first.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/ucsschool/importer/frontend/", line 243, in main
  File "/usr/lib/python3/dist-packages/ucsschool/importer/frontend/", line 166, in do_import
    six.reraise(etype, exc, etraceback)
  File "/usr/lib/python3/dist-packages/", line 693, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/ucsschool/importer/frontend/", line 152, in do_import
  File "/usr/lib/python3/dist-packages/ucsschool/importer/mass_import/", line 88, in mass_import
  File "/usr/lib/python3/dist-packages/ucsschool/importer/mass_import/", line 147, in import_users
    raise exception
  File "/usr/lib/python3/dist-packages/ucsschool/importer/mass_import/", line 122, in import_users
    user_import.create_and_modify_users(imported_users)  # 90% - 100%
  File "/usr/lib/python3/dist-packages/ucsschool/importer/mass_import/", line 222, in create_and_modify_users
    success = user.modify(lo=self.connection)
  File "/usr/lib/python3/dist-packages/ucsschool/importer/models/", line 1081, in modify
    res = super(ImportUser, self).modify(lo, validate, move_if_necessary)
  File "/usr/lib/python3/dist-packages/ucsschool/lib/models/", line 613, in modify
    success = self.modify_without_hooks(lo, validate, move_if_necessary)
  File "/usr/lib/python3/dist-packages/ucsschool/importer/models/", line 1121, in modify_without_hooks
    return super(ImportUser, self).modify_without_hooks(lo, validate, move_if_necessary)
  File "/usr/lib/python3/dist-packages/ucsschool/lib/models/", line 640, in modify_without_hooks
    self.do_modify(udm_obj, lo)
  File "/usr/lib/python3/dist-packages/ucsschool/lib/models/", line 334, in do_modify
    mandatory_groups = self.groups_used(lo)
  File "/usr/lib/python3/dist-packages/ucsschool/lib/models/", line 667, in groups_used
    self.get_or_create_group_udm_object(group_dn, lo)
  File "/usr/lib/python3/dist-packages/ucsschool/lib/models/", line 691, in get_or_create_group_udm_object
    raise RuntimeError("Work group '%s' does not exist, please create it first." % group_dn)
RuntimeError: Work group '...' does not exist, please create it first.

But the mentioned work group exists:

univention-ldapsearch -LLL cn=...
dn: ...

Environment (optional)

UCS 5.0-2 and later.


Broken group objects that lack the ucsschoolRole attribute cause this problem. The solution is to add the ucsschoolRole attribute which can be achieved by running:

udm groups/group modify --dn "..." --set ucsschoolRole="workgroup:school:..." 

Or to automatically fix all school objects:

python3 /usr/share/ucs-school-import/scripts/migrate_ucsschool_roles --modify --all-objects

Background Information

The script mentioned in the solution should have already been run by a migration (35ucs-school-import.inst, version 19). If a group exists without the ucsschoolRole attribute, it’s probably because the migration was skipped or because the group was created manually without the attribute.