harvard-lil / perma

Indelible links
420 stars 71 forks source link

Registrar user may be null, resulting in an exception when attempting to display their email #3232

Open sentry-io[bot] opened 1 year ago

sentry-io[bot] commented 1 year ago

This occurs after the successful submission of a registrar approval, but then fails on the success message to the user. If it's OK for the registrar user to be null then the message should handle that case.

Sentry Issue: PERMA-2HA

AttributeError: 'NoneType' object has no attribute 'email'
(1 additional frame(s) were not displayed)
...
  File "django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "perma/utils.py", line 96, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "perma/views/user_management.py", line 364, in approve_pending_registrar
    messages.add_message(request, messages.SUCCESS, f'Registrar request for <strong>{target_registrar}</strong> denied. Please inform {target_registrar_user.email} if appropriate.', extra_tags='safe')
rebeccacremona commented 1 year ago

Possibly related https://github.com/harvard-lil/perma/issues/3201