Bug in email fetching from DB

Issue #604 resolved
Raoul Thill
created an issue

If you have multiple users in the database, one with an email alias: firstname_name@domain.tld and and the other one with the same alias using a dot (.) instead of underscore (_) as separator, the orm throws a MultipleResultsFound error:

user = User.get_by_email(_email, case_insensitive=True, cache=True) File '/opt/rhodecode/lib/python2.6/site-packages/rhodecode/model/db.py', line 413 in get_by_email ret = q.scalar() File '/opt/rhodecode/lib/python2.6/site-packages/sqlalchemy/orm/query.py', line 2215 in scalar ret = self.one() File '/opt/rhodecode/lib/python2.6/site-packages/sqlalchemy/orm/query.py', line 2193 in one "Multiple rows were found for one()") MultipleResultsFound: Multiple rows were found for one()

Comments (6)

  1. Raoul Thill reporter

    I have used my own mail address as local administrator separated by a dot and same email address as AD user separated by underscore. Now when I try to access a repository where both users have rights to access (both admin for that repository) I get this error.

    The complete traceback as received by email may be found at http://pastebin.com/rugAfQCb

  2. Marcin Kuzminski repo owner

    Could it happen that the AD email is the same with a . ?, i think the issue is that AD E-mail Attribute returns the same address that other use have ? Can you check the DB entries are the email adress are really different ?

    In any case it's still a bug

  3. Raoul Thill reporter

    sorry for the late answer, I've tried to rebuild my issue on the demo.rhodecode.org instance, as this would make things easier, but without success. Maybe it is only an issue between the automatically created admin and newly created accounts.

    Here is the log output from my local instance, this could probably help you track down the error:

    2012-10-16 09:34:37.351 DEBUG [rhodecode.lib.middleware.simplegit] pathinfo: /IPS/Test detected as GIT False 2012-10-16 09:34:37.352 DEBUG [rhodecode.lib.middleware.simplehg] pathinfo: /IPS/Test detected as HG False 2012-10-16 09:34:37.362 DEBUG [routes.middleware] Matched GET /IPS/Test 2012-10-16 09:34:37.362 DEBUG [routes.middleware] Route path: '/{group_name:.*}', defaults: {'action': u'show_by_name', 'controller': u'admin/repos_groups'} 2012-10-16 09:34:37.363 DEBUG [routes.middleware] Match dict: {'action': u'show_by_name', 'controller': u'admin/repos_groups', 'group_name': u'IPS/Test'} 2012-10-16 09:34:37.363 DEBUG [pylons.wsgiapp] Setting up Pylons stacked object globals 2012-10-16 09:34:37.363 DEBUG [pylons.wsgiapp] Resolved URL to controller: u'admin/repos_groups' 2012-10-16 09:34:37.364 DEBUG [pylons.wsgiapp] Controller appears to be a class, instantiating 2012-10-16 09:34:37.364 DEBUG [pylons.wsgiapp] Calling controller class with WSGI interface 2012-10-16 09:34:37.364 DEBUG [beaker.container] data file /opt/rhodecode/data/sessions/container_file/0/00/00dbf5e3ee1846b5a3b89b3ac7e0f3b0.cache 2012-10-16 09:34:37.366 DEBUG [rhodecode.lib.auth] Auth User lookup by USER ID 2 2012-10-16 09:34:37.369 DEBUG [rhodecode.model.user] filling <User('id:2:admin')> data 2012-10-16 09:34:37.375 DEBUG [rhodecode.lib.auth] Auth User is now <AuthUser('id:2:admin|False')> 2012-10-16 09:34:37.388 INFO [rhodecode.lib.base] IP: 172.20.22.254 User: <AuthUser('id:2:admin|True')> accessed /IPS/Test 2012-10-16 09:34:37.388 DEBUG [pylons.controllers.core] Calling 'before' method with keyword args: {} 2012-10-16 09:34:37.389 DEBUG [rhodecode.lib.auth] Checking if admin is authenticated @ ReposGroupsController:__before__ 2012-10-16 09:34:37.389 INFO [rhodecode.lib.auth] user admin is authenticated and granted access to ReposGroupsController:__before__ using RegularAuth 2012-10-16 09:34:37.397 DEBUG [pylons.controllers.core] Looking for u'show_by_name' method to handle the request 2012-10-16 09:34:37.397 DEBUG [pylons.controllers.core] Calling 'show_by_name' method with keyword args: {'group_name': u'IPS/Test'} 2012-10-16 09:34:37.399 DEBUG [rhodecode.lib.auth] checking HasReposGroupPermissionAnyDecorator permissions set(['group.admin', 'group.read', 'group.write']) for <rhodecode.controllers.admin.repos_groups.ReposGroupsController object at 0x7f51e4992550> <AuthUser('id:2:admin|True')> 2012-10-16 09:34:37.400 DEBUG [rhodecode.lib.auth] Permission granted for <rhodecode.controllers.admin.repos_groups.ReposGroupsController object at 0x7f51e4992550> <AuthUser('id:2:admin|True')> 2012-10-16 09:34:37.409 DEBUG [rhodecode.lib.auth] checking cls:HasPermissionAll set(['hg.admin']) usr:<AuthUser('id:2:admin|True')> @ access admin main page 2012-10-16 09:34:37.409 DEBUG [rhodecode.lib.auth] Permission granted for user: <AuthUser('id:2:admin|True')> @ access admin main page 2012-10-16 09:34:37.415 DEBUG [rhodecode.lib.auth] checking cls:HasPermissionAny set(['hg.admin', 'hg.create.repository']) usr:<AuthUser('id:2:admin|True')> @ unspecified location 2012-10-16 09:34:37.415 DEBUG [rhodecode.lib.auth] Permission granted for user: <AuthUser('id:2:admin|True')> @ unspecified location 2012-10-16 09:34:37.419 DEBUG [rhodecode.model.db] Getting cached instance of repo 2012-10-16 09:34:37.420 DEBUG [rhodecode.lib.auth] checking cls:HasRepoPermissionAny set(['repository.write', 'repository.read', 'repository.admin']) usr:<AuthUser('id:2:admin|True')> repo:IPS/Test/TestLargeFiles @ get repo check 2012-10-16 09:34:37.420 DEBUG [rhodecode.lib.auth] Permission granted for user: <AuthUser('id:2:admin|True')> @ get repo check 2012-10-16 09:34:37.426 INFO [rhodecode.lib.base] IP: 172.20.22.254 Request to /IPS/Test time: 0.062s 2012-10-16 09:34:37.740 DEBUG [rhodecode.SimpleHg] Request time: 0.389s 2012-10-16 09:34:37.741 DEBUG [rhodecode.SimpleGit] Request time: 0.389s 2012-10-16 09:34:37.741 DEBUG [rhodecode.lib.middleware.simplegit] pathinfo: /error/document detected as GIT False 2012-10-16 09:34:37.741 DEBUG [rhodecode.lib.middleware.simplehg] pathinfo: /error/document detected as HG False 2012-10-16 09:34:37.742 DEBUG [routes.middleware] Matched GET /error/document 2012-10-16 09:34:37.742 DEBUG [routes.middleware] Route path: '/error/{action}', defaults: {'action': 'index', 'controller': u'error'} 2012-10-16 09:34:37.742 DEBUG [routes.middleware] Match dict: {'action': u'document', 'controller': u'error'} 2012-10-16 09:34:37.742 DEBUG [pylons.wsgiapp] Setting up Pylons stacked object globals 2012-10-16 09:34:37.743 DEBUG [pylons.wsgiapp] Resolved URL to controller: u'error' 2012-10-16 09:34:37.743 DEBUG [pylons.wsgiapp] Controller appears to be a class, instantiating 2012-10-16 09:34:37.743 DEBUG [pylons.wsgiapp] Calling controller class with WSGI interface 2012-10-16 09:34:37.744 DEBUG [beaker.container] data file /opt/rhodecode/data/sessions/container_file/0/00/00dbf5e3ee1846b5a3b89b3ac7e0f3b0.cache 2012-10-16 09:34:37.745 DEBUG [rhodecode.lib.auth] Auth User lookup by USER ID 2 2012-10-16 09:34:37.749 DEBUG [rhodecode.model.user] filling <User('id:2:admin')> data 2012-10-16 09:34:37.755 DEBUG [rhodecode.lib.auth] Auth User is now <AuthUser('id:2:admin|False')> 2012-10-16 09:34:37.768 INFO [rhodecode.lib.base] IP: 172.20.22.254 User: <AuthUser('id:2:admin|True')> accessed /IPS/Test 2012-10-16 09:34:37.768 DEBUG [pylons.controllers.core] Calling 'before' method with keyword args: {} 2012-10-16 09:34:37.769 DEBUG [pylons.controllers.core] Looking for u'document' method to handle the request 2012-10-16 09:34:37.769 DEBUG [pylons.controllers.core] Calling 'document' method with keyword args: {} 2012-10-16 09:34:37.769 DEBUG [rhodecode.controllers.error] ### 500 Internal Server Error ### 2012-10-16 09:34:37.770 DEBUG [pylons.controllers.core] Controller returned a unicode string , writing it to pylons.response 2012-10-16 09:34:37.770 DEBUG [pylons.controllers.core] Calling Response object to return WSGI data 2012-10-16 09:34:37.771 INFO [rhodecode.lib.base] IP: 172.20.22.254 Request to /IPS/Test time: 0.027s 2012-10-16 09:34:37.771 DEBUG [rhodecode.SimpleHg] Request time: 0.030s 2012-10-16 09:34:37.772 DEBUG [rhodecode.SimpleGit] Request time: 0.031s

  4. Log in to comment