Problem: Traceback beim Löschen von Usern während des Imports

Problem

Der Import bricht beim Löschen von Usern mit einem Traceback ab:

2021-11-16 02:00:11 DEBUG base.get_only_udm_obj:1169  Getting Group UDM object by filter: name=schueler-Testschule
2021-11-16 02:00:11 DEBUG base.from_dn:1142  Looking up SchoolClass with dn 'cn=schueler-Testschule,cn=groups,ou=Testschule,dc=Auenland,dc=intranet'
2021-11-16 02:00:11 WARNING base.from_udm_obj:1055  UDM object 'cn=schueler-Testschule,cn=groups,ou=Testschule,dc=Auenland,dc=intranet' does not correspond to a Python class in the UCS school lib.
2021-11-16 02:00:11 ERROR user_import.delete_users:510  Error in entry #0: UDM properties 'username' must be set as attributes of the ImportStudent object (not in udm_properties).
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/ucsschool/importer/mass_import/user_import.py", line 491, in delete_users
    success = self.do_delete(user)
  File "/usr/lib/python2.7/dist-packages/ucsschool/importer/mass_import/user_import.py", line 625, in do_delete
    success = user.modify(lo=self.connection, validate=False)
  File "/usr/lib/python2.7/dist-packages/ucsschool/importer/models/import_user.py", line 1057, in modify
    res = super(ImportUser, self).modify(lo, validate, move_if_necessary)
  File "/usr/lib/python2.7/dist-packages/ucsschool/lib/models/base.py", line 674, in modify
    success = self.modify_without_hooks(lo, validate, move_if_necessary)
  File "/usr/lib/python2.7/dist-packages/ucsschool/importer/models/import_user.py", line 1093, in modify_without_hooks
    return super(ImportUser, self).modify_without_hooks(lo, validate, move_if_necessary)
  File "/usr/lib/python2.7/dist-packages/ucsschool/lib/models/base.py", line 701, in modify_without_hooks
    self.do_modify(udm_obj, lo)
  File "/usr/lib/python2.7/dist-packages/ucsschool/lib/models/user.py", line 330, in do_modify
    return super(User, self).do_modify(udm_obj, lo)
  File "/usr/lib/python2.7/dist-packages/ucsschool/lib/models/base.py", line 735, in do_modify
    self._alter_udm_obj(udm_obj)
  File "/usr/lib/python2.7/dist-packages/ucsschool/importer/models/import_user.py", line 501, in _alter_udm_obj
    self._prevent_mapped_attributes_in_udm_properties()
  File "/usr/lib/python2.7/dist-packages/ucsschool/importer/models/import_user.py", line 1591, in _prevent_mapped_attributes_in_udm_properties
    "udm_properties).".format("', '".join(bad_props), self.__class__.__name__)
NotSupportedError: UDM properties 'username' must be set as attributes of the ImportStudent object (not in udm_properties).
2021-11-16 02:00:11 ERROR mass_import.import_users:128  More than 0 errors.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/ucsschool/importer/mass_import/mass_import.py", line 124, in import_users
    user_import.delete_users(users_to_delete)  # 0% - 10%
  File "/usr/lib/python2.7/dist-packages/ucsschool/importer/mass_import/user_import.py", line 511, in delete_users
    self._add_error(exc)
  File "/usr/lib/python2.7/dist-packages/ucsschool/importer/mass_import/user_import.py", line 792, in _add_error
    "More than {} errors.".format(self.config["tolerate_errors"]), self.errors

Environment

UCS@school 4.4 v9

Solution

Im Mapping wurde das UDM Property username eingetragen. Im Mapping soll, wenn vorhanden, das Attribut der ImportUser Klasse eingetragen werden. In diesem Fall statt username nur name

"csv": {
	"mapping": {
		"Nutzername": "name",
		"Schule": "school",
		"Schulen": "schools",
		"Vorname": "firstname",
		"Nachname": "lastname",
		"Geburtstag": "birthday",
		"Mailadresse": "email"
		"Passwort": "password",
		"Aktiviert": "disabled",
		"Schulklassen": "school_classes",
		"Quell-ID": "source_uid",
		"RecordID": "record_uid"
}

Root Cause

Bei UCS@school 4.4 v9 ist es durch Behebung eines Bugs zu einer Regression gekommen. Wir haben normalerweise einen “doppelten Boden” programmiert. Wird im Mapping eine Angabe gefunden, die nicht einem Attribut der ImportUser Klasse entspricht, wir geprüft, ob es ein solches UDM Property existiert. Diese Prüfung für das UDM Property username bei der Löschung eines Users vergessen worden. Siehe Bug 54131