mitodl / micromasters

Portal for learners and course teams to access MITx Micromasters® programs
https://mm.mit.edu
BSD 3-Clause "New" or "Revised" License
29 stars 17 forks source link

Staff user gets 500 error when CMS "staff" setting is set to false #3723

Open pdpinch opened 6 years ago

pdpinch commented 6 years ago

AttributeError: 'NoneType' object has no attribute 'permission_names_list'

https://sentry.io/mit-office-of-digital-learning/micromasters/issues/418524267/

This started happening shortly after I granted this user access to the CMS, so it might be related somehow to Wagtail

AttributeError: 'NoneType' object has no attribute 'permission_names_list'
(14 additional frame(s) were not displayed)
...
  File "ui/decorators.py", line 31, in wrapper
    return func(request, *args, **kwargs)
  File "ui/views.py", line 45, in get
    } for role in user.role_set.all()
  File "ui/views.py", line 45, in <listcomp>
    } for role in user.role_set.all()
  File "rolepermissions/shortcuts.py", line 63, in available_perm_status
    permission_names = role.permission_names_list()

AttributeError: 'NoneType' object has no attribute 'permission_names_list'
pdpinch commented 6 years ago

It appears that the cause of this is an issue in Wagtail where get_user_role(user) returns None if the user has some roles, but not the staff role. I.e.

screenshot 2017-12-14 14 50 43
pdpinch commented 6 years ago

The short-term workaround was to give the user the "staff" permission in the CMS. That cleared the error, but I'd still like to know

a) Why the dashboard needs to access CMS permissions? (Perhaps in order to build the side nav) b) Why this particular CMS role is necessary