Project

General

Profile

Bug #5636

Remap and Rescan 500 Internal Server Error

Added by Alex Marchak about 1 month ago. Updated about 1 month ago.

Status:
New
Priority:
High
Assignee:
-
Category:
-
Target version:
-
Start date:
29.10.2020
Due date:
% Done:

0%

Estimated time:
Sorting:
Commit Number:
Affected Version:

Description

Pressing button Remap and Rescan causes 500 with and without "Destroy old data" " Invalidate cache for all repositories" options.

Target repositories directory can be even empty.
With or without changes(new repos added).

OS: Debian 9.9
RHODECODE versions: 4.22.0
RHODECODE license: CE

Exception log:

Exception `TypeError` generated on UTC date: 2020-10-29T07:47:10.580519
Request: POST http://xxx.xxx.xxx.xxx/_admin/settings/mapping/update
yyy.yyy.yyy.yyy Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36

Traceback (most recent call last):
  File "/opt/rhodecode/store/da2il1f83gci4333j0sd256nji9nlhpa-python2.7-pyramid-1.10.4/lib/python2.7/site-packages/pyramid/tweens.py", line 41, in excview_tween
    response = handler(request)
  File "/opt/rhodecode/store/da2il1f83gci4333j0sd256nji9nlhpa-python2.7-pyramid-1.10.4/lib/python2.7/site-packages/pyramid/router.py", line 148, in handle_request
    registry, request, context, context_iface, view_name
  File "/opt/rhodecode/store/da2il1f83gci4333j0sd256nji9nlhpa-python2.7-pyramid-1.10.4/lib/python2.7/site-packages/pyramid/view.py", line 667, in _call_view
    response = view_callable(context, request)
  File "/opt/rhodecode/store/da2il1f83gci4333j0sd256nji9nlhpa-python2.7-pyramid-1.10.4/lib/python2.7/site-packages/pyramid/config/views.py", line 188, in attr_view
    return view(context, request)
  File "/opt/rhodecode/store/da2il1f83gci4333j0sd256nji9nlhpa-python2.7-pyramid-1.10.4/lib/python2.7/site-packages/pyramid/config/views.py", line 214, in predicate_wrapper
    return view(context, request)
  File "/opt/rhodecode/store/da2il1f83gci4333j0sd256nji9nlhpa-python2.7-pyramid-1.10.4/lib/python2.7/site-packages/pyramid/viewderivers.py", line 436, in rendered_view
    result = view(context, request)
  File "/opt/rhodecode/store/da2il1f83gci4333j0sd256nji9nlhpa-python2.7-pyramid-1.10.4/lib/python2.7/site-packages/pyramid/viewderivers.py", line 132, in _class_view
    response = getattr(inst, attr)()
  File "/opt/rhodecode/store/cnpzq6z5xjxzxw2m3d1cfb5yhpazscn5-python2.7-rhodecode-enterprise-ce-4.22.0/lib/python2.7/site-packages/rhodecode/lib/auth.py", line 2507, in local_wrapper
    return wrapper(func, *args, **kwds)
  File "/opt/rhodecode/store/cnpzq6z5xjxzxw2m3d1cfb5yhpazscn5-python2.7-rhodecode-enterprise-ce-4.22.0/lib/python2.7/site-packages/rhodecode/lib/auth.py", line 1823, in __wrapper
    return func(*fargs, **fkwargs)
  File "/opt/rhodecode/store/cnpzq6z5xjxzxw2m3d1cfb5yhpazscn5-python2.7-rhodecode-enterprise-ce-4.22.0/lib/python2.7/site-packages/rhodecode/lib/auth.py", line 2507, in local_wrapper
    return wrapper(func, *args, **kwds)
  File "/opt/rhodecode/store/cnpzq6z5xjxzxw2m3d1cfb5yhpazscn5-python2.7-rhodecode-enterprise-ce-4.22.0/lib/python2.7/site-packages/rhodecode/lib/auth.py", line 1897, in __wrapper
    return func(*fargs, **fkwargs)
  File "/opt/rhodecode/store/cnpzq6z5xjxzxw2m3d1cfb5yhpazscn5-python2.7-rhodecode-enterprise-ce-4.22.0/lib/python2.7/site-packages/rhodecode/lib/auth.py", line 2507, in local_wrapper
    return wrapper(func, *args, **kwds)
  File "/opt/rhodecode/store/cnpzq6z5xjxzxw2m3d1cfb5yhpazscn5-python2.7-rhodecode-enterprise-ce-4.22.0/lib/python2.7/site-packages/rhodecode/lib/auth.py", line 1716, in __wrapper
    return func(*fargs, **fkwargs)
  File "/opt/rhodecode/store/cnpzq6z5xjxzxw2m3d1cfb5yhpazscn5-python2.7-rhodecode-enterprise-ce-4.22.0/lib/python2.7/site-packages/rhodecode/apps/admin/views/settings.py", line 266, in settings_mapping_update
    PermissionModel().trigger_permission_flush()
  File "/opt/rhodecode/store/cnpzq6z5xjxzxw2m3d1cfb5yhpazscn5-python2.7-rhodecode-enterprise-ce-4.22.0/lib/python2.7/site-packages/rhodecode/model/permission.py", line 582, in trigger_permission_flush
    events.trigger(events.UserPermissionsChange(affected_user_ids))
  File "/opt/rhodecode/store/cnpzq6z5xjxzxw2m3d1cfb5yhpazscn5-python2.7-rhodecode-enterprise-ce-4.22.0/lib/python2.7/site-packages/rhodecode/events/__init__.py", line 38, in trigger
    registry.notify(event)
  File "/opt/rhodecode/store/da2il1f83gci4333j0sd256nji9nlhpa-python2.7-pyramid-1.10.4/lib/python2.7/site-packages/pyramid/registry.py", line 109, in notify
    [_ for _ in self.subscribers(events, None)]
  File "/opt/rhodecode/store/x5ng3z8k1rbbxk56dqsa9ri450ka0c4h-python2.7-zope.interface-4.6.0/lib/python2.7/site-packages/zope/interface/registry.py", line 442, in subscribers
    return self.adapters.subscribers(objects, provided)
  File "/opt/rhodecode/store/x5ng3z8k1rbbxk56dqsa9ri450ka0c4h-python2.7-zope.interface-4.6.0/lib/python2.7/site-packages/zope/interface/adapter.py", line 607, in subscribers
    subscription(*objects)
  File "/opt/rhodecode/store/da2il1f83gci4333j0sd256nji9nlhpa-python2.7-pyramid-1.10.4/lib/python2.7/site-packages/pyramid/config/adapters.py", line 101, in derived_subscriber
    return subscriber(arg[0])
  File "/opt/rhodecode/store/cnpzq6z5xjxzxw2m3d1cfb5yhpazscn5-python2.7-rhodecode-enterprise-ce-4.22.0/lib/python2.7/site-packages/rhodecode/apps/_base/subscribers.py", line 45, in trigger_user_permission_flush
    affected_user_ids = set(event.user_ids)
TypeError: 'NoneType' object is not iterable

History

#1 Updated by Marcin Kuzminski [CTO] about 1 month ago

We'll look into this.

#2 Updated by Alex Marchak about 1 month ago

Marcin Kuzminski [CTO] wrote:

We'll look into this.

Not sue, but problem is related to this commit https://code.rhodecode.com/rhodecode-enterprise-ce/changeset/61666194d16389942f801c3a43bd5c39af27df49

Removing code and building from source code helped.

#3 Updated by Daniel D about 1 month ago

Thanks for reporting this, indeed it's a bug. Here's a proper patch to fix it.

diff --git a/rhodecode/model/permission.py b/rhodecode/model/permission.py
--- a/rhodecode/model/permission.py
+++ b/rhodecode/model/permission.py
@@ -573,17 +573,17 @@ class PermissionModel(BaseModel):

         # write or higher and DEFAULT user for inheritance
         for p in db_repo.permission_user_groups():
             if p.permission in write_plus:
                 user_group_write_permissions[p.users_group_id] = p
         return user_group_write_permissions

     def trigger_permission_flush(self, affected_user_ids=None):
-        affected_user_ids or User.get_all_user_ids()
+        affected_user_ids = affected_user_ids or User.get_all_user_ids()
         events.trigger(events.UserPermissionsChange(affected_user_ids))

     def flush_user_permission_caches(self, changes, affected_user_ids=None):
         affected_user_ids = affected_user_ids or []

         for change in changes['added'] + changes['updated'] + changes['deleted']:
             if change['type'] == 'user':
                 affected_user_ids.append(change['id'])

Also available in: Atom PDF