Bug 52226 - Traceback while activating E-Mail for workgroup and changing workgroup name at the same time
Traceback while activating E-Mail for workgroup and changing workgroup name a...
Status: NEW
Product: UCS@school
Classification: Unclassified
Component: UMC - Classes / Teachers / Workgroup assignment
UCS@school 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: UCS@school maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-10-15 17:17 CEST by Ingo Steuwer
Modified: 2023-06-23 13:39 CEST (History)
3 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: ---
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 Ingo Steuwer univentionstaff 2020-10-15 17:17:11 CEST
Steps:

- create a new workgroup without E-Mail address, save
- edit the workgroup, activate the E-Mail address (do not save yet) and afterwards change the group name
- try to save

Traceback:

Interner Server-Fehler in "schoolgroups/put (workgroup-admin)".
Request: schoolgroups/put (workgroup-admin)

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/univention/management/console/base.py", line 359, in __error_handling
    six.reraise(etype, exc, etraceback)
  File "/usr/lib/python2.7/dist-packages/univention/management/console/base.py", line 262, in execute
    function.__func__(self, request, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/univention/management/console/modules/decorators.py", line 181, in _response
    return function(self, request)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/school_umc_ldap_connection.py", line 140, in wrapper_func
    return func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/schoolgroups/__init__.py", line 326, in put
    success = group_from_ldap.modify(ldap_machine_write)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 567, in modify
    success = self.modify_without_hooks(lo, validate, move_if_necessary)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/group.py", line 246, in modify_without_hooks
    success = super(SchoolClass, self).modify_without_hooks(lo, validate, move_if_necessary)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 584, in modify_without_hooks
    raise ValidationError(self.errors.copy())
ValidationError: {'email': ['Keine g\xc3\xbcltige E-Mail-Adresse']}
Comment 1 Ingo Steuwer univentionstaff 2020-10-15 17:24:36 CEST
OK, this is not related to the change of the _description_ (one can't change the name). The root cause of the traceback is the same as in Bug #52225 - only that in this case the UDM exception isn't catched.
Comment 2 Ole Schwiegert univentionstaff 2020-10-16 07:27:43 CEST
True, for modifications catching the ValidationError was overlooked. Luckily the fix is easy:

        try:
            success = group_from_ldap.modify(ldap_machine_write)
            MODULE.info("Modified, group has now members: %s" % (group_from_ldap.users,))
        except udm_exceptions.base as exc:
            MODULE.process(
                'An error occurred while modifying "%s": %s' % (group_from_umc["$dn$"], exc.message)
            )
            raise UMC_Error(_("Failed to modify group (%s).") % exc.message)

just except ValidationError as exc:
    [...]
Comment 3 Florian Best univentionstaff 2020-10-26 09:35:06 CET
(In reply to Ole Schwiegert from comment #2)
> True, for modifications catching the ValidationError was overlooked. Luckily
> the fix is easy:
> 
>         try:
>             success = group_from_ldap.modify(ldap_machine_write)
>             MODULE.info("Modified, group has now members: %s" %
> (group_from_ldap.users,))
>         except udm_exceptions.base as exc:
>             MODULE.process(
>                 'An error occurred while modifying "%s": %s' %
> (group_from_umc["$dn$"], exc.message)
>             )
>             raise UMC_Error(_("Failed to modify group (%s).") % exc.message)
> 
> just except ValidationError as exc:
>     [...]

Can you provide fixes as patch? This looks very much like a typo/copy paste error: `group_from_umc["$dn$"]`