Kallithea issues archive

Issue #28: Viewing notifications page with incomplete profile results in error

Reported by: Stefan Walter
State: resolved
Created on: 2014-09-03 08:22
Updated on: 2014-09-24 17:53

Description

We are currently testing a 0.1 setup with authentication done by the container and Kallithea accounts being created automatically on first login. We noticed an error in the following situation:

  1. A new user logged in for the first time.
  2. The user added a comment to a line in a changeset.
  3. The user tried to view his notifications by moving the mouse pointer to his user name (upper right corner) and clicking on the "Notifications" link.

The result was an error page being shown and the following stack trace being mailed to me:

Module kallithea.controllers.admin.notifications:81 in index
>>  return render('admin/notifications/notifications.html')
Module pylons.templating:243 in render_mako
>>  cache_type=cache_type, cache_expire=cache_expire)
Module pylons.templating:218 in cached_template
>>  return render_func()
Module pylons.templating:240 in render_template
>>  return literal(template.render_unicode(**globs))
Module mako.template:452 in render_unicode
>>  as_unicode=True)
Module mako.runtime:803 in _render
>>  **_kwargs_for_callable(callable_, data))
Module mako.runtime:835 in _render_context
>>  _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
Module mako.runtime:855 in _exec_template
>>  _render_error(template, context, compat.exception_as())
Module mako.runtime:864 in _render_error
>>  result = template.error_handler(context, error)
Module mako.runtime:853 in _exec_template
>>  callable_(context, *args, **kwargs)
Module _base_root_html:44 in render_body
>>  __M_writer(escape(next.body()))
Module _base_base_html:55 in render_body
>>  __M_writer(escape(next.main()))
Module admin_notifications_notifications_html:72 in render_main
>>  runtime._include_file(context, u'notifications_data.html', _template_uri)
Module mako.runtime:730 in _include_file
>>  callable_(ctx, **_kwargs_for_include(callable_, context._data, **kwargs))
Module admin_notifications_notifications_data_html:41 in render_body
>>  __M_writer(escape(h.gravatar_url(h.email_or_none(notification.notification.created_by_user.email),24)))
Module kallithea.lib.helpers:500 in email_or_none
>>  _email = email(author)
Module kallithea.lib.vcs.utils:162 in author_email
>>  r = author.find('>')

Afterwards, the user opened his profile page. The "First Name" field was initialized to his account name, the "Last Name" and "Email" fields were empty. He entered a name and e-mail address and could then open the notifications page without causing an error.

Attachments

Comments

Comment by Mads Kiilerich, on 2014-09-03 15:04

The email must have contained a bit more - some of it is essential information. Please provide that as well.

Comment by Mads Kiilerich, on 2014-09-03 16:17

@andrew_shadura - this seems closely related to 5ebd887522ea - will you look at this too?

I guess author is None.

Comment by Stefan Walter, on 2014-09-04 09:30

Oh...first I thought you meant the CGI or WSGI variables, but couldn't see anything that might help with finding the problem in the code. Then I noticed I had left out the actual message because it was rendered as bold and I must have mis-recognized and ignored it as a header for the following text. Yes, it looks like author is None. Here's the complete trace:

Module kallithea.controllers.admin.notifications:81 in index
>>  return render('admin/notifications/notifications.html')
Module pylons.templating:243 in render_mako
>>  cache_type=cache_type, cache_expire=cache_expire)
Module pylons.templating:218 in cached_template
>>  return render_func()
Module pylons.templating:240 in render_template
>>  return literal(template.render_unicode(**globs))
Module mako.template:452 in render_unicode
>>  as_unicode=True)
Module mako.runtime:803 in _render
>>  **_kwargs_for_callable(callable_, data))
Module mako.runtime:835 in _render_context
>>  _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
Module mako.runtime:855 in _exec_template
>>  _render_error(template, context, compat.exception_as())
Module mako.runtime:864 in _render_error
>>  result = template.error_handler(context, error)
Module mako.runtime:853 in _exec_template
>>  callable_(context, *args, **kwargs)
Module _base_root_html:44 in render_body
>>  __M_writer(escape(next.body()))
Module _base_base_html:55 in render_body
>>  __M_writer(escape(next.main()))
Module admin_notifications_notifications_html:72 in render_main
>>  runtime._include_file(context, u'notifications_data.html', _template_uri)
Module mako.runtime:730 in _include_file
>>  callable_(ctx, **_kwargs_for_include(callable_, context._data, **kwargs))
Module admin_notifications_notifications_data_html:41 in render_body
>>  __M_writer(escape(h.gravatar_url(h.email_or_none(notification.notification.created_by_user.email),24)))
Module kallithea.lib.helpers:500 in email_or_none
>>  _email = email(author)
Module kallithea.lib.vcs.utils:162 in author_email
>>  r = author.find('>')
AttributeError: 'NoneType' object has no attribute 'find'

Comment by Mads Kiilerich, on 2014-09-17 09:03

Andrew seems to be MIA.

Stefan, can you confirm this fixes the issue:

--- a/kallithea/lib/helpers.py
+++ b/kallithea/lib/helpers.py
@@ -496,6 +496,8 @@ def is_hg(repository):


 def email_or_none(author):
+    if not author:
+        return None
     # extract email from the commit string
     _email = email(author)
     if _email:

Comment by Stefan Walter, on 2014-09-19 07:31

I'll verify it as soon as I get to it.

Comment by Stefan Walter, on 2014-09-23 16:25

I just tested the patch and can confirm that it fixes the issue for me. Thank you!

Comment by Mads Kiilerich, on 2014-09-24 17:53

Fix pushed.