Univention Bugzilla – Bug 47861
Misleading error message if class name contains invalid characters
Last modified: 2018-12-19 16:51:23 CET
I just helped the third time to debug an import error message that occurred on a customer production system: The error message is: Importfehler: 2018-09-26 09:52:16 INFO user_import.log_stats:496 0: fkraemer: ValidationError when adding ImportTeacher(name='fkraemer', school=u'0702129', dn=u'uid=fkraemer,cn=lehrer,cn=users,ou=0702129,dc=schule,dc=luebeck,dc=de', old_dn=None) (source_uid:0702129-teacher record_uid: 5065911): {'name': ['Value may not contain other than numbers, letters and dots!']} Unfortunately this is not very helpful, since it's not the username, firstname or lastname the contained invalid data. It was the class name: 2018-09-26 09:52:13 INFO base.create_without_hooks:435 Creating SchoolClass(name='1234567-1/2b - Foobar', school=u'1234567', dn=u'cn=1234567-1/2b - Foobar,cn=klassen,cn=schueler,cn=groups,ou=1234567,dc=schule,dc=example,dc=com') The import should either check the class name before the actual import starts or the returned error message should be more appropriate (→ state that it is the class name that is broken). Additionally the manual should be updated and should contain a statement about the valid character set: UDM syntax is "gid" → re.compile(ur"(?u)^\w([\w -.’]*\w)?$") 2018-09-26 09:52:13 INFO base.create_without_hooks:435 Creating SchoolClass(name='1234567-1/2b - Foobar', school=u'1234567', dn=u'cn=1234567-1/2b - Foobar,cn=klassen,cn=schueler,cn=groups,ou=1234567,dc=schule,dc=example,dc=com') 2018-09-26 09:52:13 ERROR user_import.create_and_modify_users:177 Entry #0: ValidationError when adding ImportTeacher(name='flastname', school=u'1234567', dn=u'uid=flastname,cn=lehrer,cn=users,ou=1234567,dc=schule,dc=example,dc=com', old_dn=None) (source_uid:1234567-teacher record_uid: 987654): {'name': ['Value may not contain other than numbers, letters and dots!']} Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/ucsschool/importer/mass_import/user_import.py", line 147, in create_and_modify_users success = user.create(lo=self.connection) File "/usr/lib/pymodules/python2.7/ucsschool/importer/models/import_user.py", line 300, in create return super(ImportUser, self).create(lo, validate) File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 427, in create success = self.create_without_hooks(lo, validate) File "/usr/lib/pymodules/python2.7/ucsschool/importer/models/import_user.py", line 304, in create_without_hooks return super(ImportUser, self).create_without_hooks(lo, validate) File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 453, in create_without_hooks self.do_create(udm_obj, lo) File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/user.py", line 232, in do_create udm_obj['groups'] = self.groups_used(lo) File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/user.py", line 474, in groups_used self.get_or_create_group_udm_object(group_dn, lo) File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/user.py", line 488, in get_or_create_group_udm_object group.create(lo) File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 427, in create success = self.create_without_hooks(lo, validate) File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/group.py", line 192, in create_without_hooks success = super(SchoolClass, self).create_without_hooks(lo, validate) File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 440, in create_without_hooks raise ValidationError(self.errors.copy()) UserValidationError: ValidationError when adding ImportTeacher(name='flastname', school=u'1234567', dn=u'uid=flastname,cn=lehrer,cn=users,ou=1234567,dc=schule,dc=example,dc=com', old_dn=None) (source_uid:1234567-teacher record_uid: 987654): {'name': ['Value may not contain other than numbers, letters and dots!']}
(In reply to Sönke Schwardt-Krummrich from comment #0) > I just helped the third time to debug an import error message that occurred > on a customer production system: > > The error message is: > Importfehler: 2018-09-26 09:52:16 INFO user_import.log_stats:496 0: > fkraemer: ValidationError when adding ImportTeacher(name='fkraemer', > school=u'0702129', > dn=u'uid=fkraemer,cn=lehrer,cn=users,ou=0702129,dc=schule,dc=luebeck,dc=de', > old_dn=None) (source_uid:0702129-teacher record_uid: 5065911): {'name': > ['Value may not contain other than numbers, letters and dots!']} > > Unfortunately this is not very helpful, since it's not the username, > firstname or lastname the contained invalid data. It was the class name: > 2018-09-26 09:52:13 INFO base.create_without_hooks:435 Creating > SchoolClass(name='1234567-1/2b - Foobar', school=u'1234567', > dn=u'cn=1234567-1/2b - > Foobar,cn=klassen,cn=schueler,cn=groups,ou=1234567,dc=schule,dc=example, > dc=com') > > The import should either check the class name before the actual import > starts or the returned error message should be more appropriate (→ state > that it is the class name that is broken). The way errors are currently aggregated it won't be possible to tell where the error originated. Checking the group name syntax won't be a problem though. > Additionally the manual should be updated and should contain a statement > about the valid character set: > UDM syntax is "gid" → re.compile(ur"(?u)^\w([\w -.’]*\w)?$") ACK [..] > UserValidationError: ValidationError when adding > ImportTeacher(name='flastname', school=u'1234567', > dn=u'uid=flastname,cn=lehrer,cn=users,ou=1234567,dc=schule,dc=example, > dc=com', old_dn=None) (source_uid:1234567-teacher record_uid: 987654): > {'name': ['Value may not contain other than numbers, letters and dots!']}
The UDM error messages can be more exact. I have modified them, so their origin can be determined: [dtroeder/47861_better_error_msg 0cf170b1f7] Bug #47861: make error messages more explicit I'm looking for a french translation, or we'll leave it like this for now.
>>> user = ImportStudent(name='testuser2', school='SchuleEins', firstname='fn', lastname='ln', password='univention', source_uid='TestDB', record_uid='testuser2', school_classes={'SchuleEins': ['SchuleEins-1/a']}) >>> user.create(lo) ValidationError: {'name': ['A group name may not contain other characters than numbers, letters and dots!']}
The above command user.create(lo) is now caught already in ImportUser.validate() before reaching UDM. So it will be caught in dry-run too. [4.3 5fed2adbe] Bug #47861: catch invalid group name ucs-school-import (16.0.2-56) In the absence of a french translation, and because the existing translations are OK for now, I have also merged the UDM code. [4.3-2] abbcd72bfa Bug #47861: make error messages more explicit [4.3-2] dc16dc7194 Bug #47861: changelog [4.3-2] a2aeb24d5d Bug #47861: advisories univention-directory-manager-modules (13.0.24-2) univention-l10n-fr (2.0.0-9)
(In reply to Daniel Tröder from comment #4) > The above command user.create(lo) is now caught already in > ImportUser.validate() before reaching UDM. So it will be caught in dry-run > too. > > [4.3 5fed2adbe] Bug #47861: catch invalid group name > > ucs-school-import (16.0.2-56) > > In the absence of a french translation, and because the existing > translations are OK for now, I have also merged the UDM code. > > [4.3-2] abbcd72bfa Bug #47861: make error messages more explicit > [4.3-2] dc16dc7194 Bug #47861: changelog > [4.3-2] a2aeb24d5d Bug #47861: advisories > > univention-directory-manager-modules (13.0.24-2) > univention-l10n-fr (2.0.0-9) REOPEN: "...may not contain other characters than numbers, letters and dots!" is wrong for Syntaxes gid, (partially for) dnsHostname and dnsName_umlauts. As far as I can see, space (" "), underscores, dashes and dots are sometimes allowed and sometimes not. If we alter these exception, please adapt them so they are returning the correct message according to their regexes.
The syntax error messages were improved. [4.3-2] 27c0673c1b Bug #47861: make error messages more accurate [4.3-2] b4a9972913 Bug #47861: bump [4.3-2] 9a552bbf36 Bug #47861: fix fuzzy entry [4.3-2] 6c0725593a Bug #47861: advisory update univention-directory-manager-modules 13.0.25 univention-l10n-fr 2.0.0-10
*** Bug 48003 has been marked as a duplicate of this bug. ***
The name for mailing lists used the same sytax class and got a mismatching error message now. Added a separate syntax class with appropriate message for it. [4.3-2 d52919fb7c] Bug #47861: add separate syntax class for mailing list names [4.3-2 6cef712d28] Bug #47861: update advisory [4.3-2 321c4f2656] Bug #47861: add support for new syntax class mailinglist_name [4.3-2 82f09771a4] Bug #47861: update advisory Adapted univention-ox source code to match the new message and thus have a translation. No need to QA this. [4.3 017cdb6] Bug #47861: adapt error message to match translation in UDM univention-directory-manager-modules 13.0.25 univention-l10n-fr 2.0.0-11
Ok, works YAML: slightly updated
<http://errata.software-univention.de/ucs/4.3/284.html> <http://errata.software-univention.de/ucs/4.3/285.html>