Issue #303 resolved

Error when accessing users groups

Soren Mathiasen
created an issue

Hi,

When trying to access the users groups menu as the admin user, we get the following error.

Error - <type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'username' URL: https://192.168.16.85/_admin/users_groups File '/usr/local/lib/python2.7/dist-packages/weberror/errormiddleware.py', line 162 in call app_iter = self.application(environ, sr_checker) File '/usr/local/lib/python2.7/dist-packages/RhodeCode-1.2.3-py2.7.egg/rhodecode/lib/middleware/simplegit.py', line 106 in call return self.application(environ, start_response) File '/usr/local/lib/python2.7/dist-packages/RhodeCode-1.2.3-py2.7.egg/rhodecode/lib/middleware/simplehg.py', line 71 in call return self.application(environ, start_response) File '/usr/local/lib/python2.7/dist-packages/beaker/middleware.py', line 152 in call return self.wrap_app(environ, session_start_response) File '/usr/local/lib/python2.7/dist-packages/routes/middleware.py', line 131 in call response = self.app(environ, start_response) File '/usr/local/lib/python2.7/dist-packages/pylons/wsgiapp.py', line 107 in call response = self.dispatch(controller, environ, start_response) File '/usr/local/lib/python2.7/dist-packages/pylons/wsgiapp.py', line 312 in dispatch return controller(environ, start_response) File '/usr/local/lib/python2.7/dist-packages/RhodeCode-1.2.3-py2.7.egg/rhodecode/lib/base.py', line 52 in call return WSGIController.call(self, environ, start_response) File '/usr/local/lib/python2.7/dist-packages/pylons/controllers/core.py', line 211 in call response = self._dispatch_call() File '/usr/local/lib/python2.7/dist-packages/pylons/controllers/core.py', line 162 in _dispatch_call response = self._inspect_call(func) File '/usr/local/lib/python2.7/dist-packages/pylons/controllers/core.py', line 105 in _inspect_call result = self._perform_call(func, args) File '/usr/local/lib/python2.7/dist-packages/pylons/controllers/core.py', line 57 in _perform_call return func(args) File '/usr/local/lib/python2.7/dist-packages/RhodeCode-1.2.3-py2.7.egg/rhodecode/controllers/admin/users_groups.py', line 64 in index return render('admin/users_groups/users_groups.html') File '/usr/local/lib/python2.7/dist-packages/pylons/templating.py', line 243 in render_mako cache_type=cache_type, cache_expire=cache_expire) File '/usr/local/lib/python2.7/dist-packages/pylons/templating.py', line 218 in cached_template return render_func() File '/usr/local/lib/python2.7/dist-packages/pylons/templating.py', line 240 in render_template return literal(template.render_unicode(globs)) File '/usr/local/lib/python2.7/dist-packages/mako/template.py', line 311 in render_unicode as_unicode=True) File '/usr/local/lib/python2.7/dist-packages/mako/runtime.py', line 660 in _render kwargs_for_callable(callable, data)) File '/usr/local/lib/python2.7/dist-packages/mako/runtime.py', line 692 in render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs) File '/usr/local/lib/python2.7/dist-packages/mako/runtime.py', line 713 in _exec_template _render_error(template, context, e) File '/usr/local/lib/python2.7/dist-packages/mako/runtime.py', line 722 in _render_error result = template.error_handler(context, error) File '/usr/local/lib/python2.7/dist-packages/mako/runtime.py', line 711 in _exec_template callable(context, *args, kwargs) File '/home/schantz/rhodecode/data/templates/base/root.html.py', line 62 in render_body M_writer(escape(next.body())) File '/home/schantz/rhodecode/data/templates/base/base.html.py', line 160 in render_body M_writer(escape(next.main())) File '/home/schantz/rhodecode/data/templates/admin/users_groups/users_groups.html.py', line 88 in render_main __M_writer(escape(', '.join([x.user.username for x in u_group.members[:50]]))) AttributeError: 'NoneType' object has no attribute 'username'

Comments (5)

  1. Marcin Kuzminski repo owner

    This is a problem of FK not doing a cascade delete when removing user. That's why i asked from what version you are using it. You deleted an user that was in some group, and now he's still referenced in userToGroup assignment.

    To fix this delete entries from table users_groups_members which references users that are not present in users table

  2. Soren Mathiasen reporter

    Fixed using the following sql delete from users_groups_members where users_group_member_id not in ( select users_group_member_id from users_groups_members join users on users.user_id = users_groups_members.user_id )

  3. Log in to comment