An error occurs when accessing /users/userinfo/ after deleting a user:AttributeError: 'AnonymousUserMixin' object has no attribute 'id' #33825
Replies: 1 comment 2 replies
-
This error happens because Flask-AppBuilder's userinfo view doesn't check if the user is anonymous before accessing g.user.id. When you delete a user but the session remains, g.user becomes an AnonymousUserMixin, which lacks an id attribute, causing the AttributeError. To fix this: log out and log back in, or clear your browser's session cookies to remove any lingering references to the deleted user. If you have custom session or authentication logic, make sure it handles deleted users gracefully. For a more robust fix, consider overriding the FAB userinfo view to check for anonymous users before accessing user attributes, or update FAB if a patch becomes available. More details and workarounds are discussed here. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
error detail:
2025-06-19 17:36:36,952:WARNING:superset.views.error_handling:Exception
Traceback (most recent call last):
File "/home/ubuntu/venv/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ubuntu/venv/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/home/ubuntu/venv/lib/python3.10/site-packages/flask_appbuilder/security/decorators.py", line 151, in wraps
return f(self, *args, **kwargs)
File "/home/ubuntu/venv/lib/python3.10/site-packages/flask_appbuilder/security/views.py", line 287, in userinfo
item = self.datamodel.get(g.user.id, self._base_filters)
AttributeError: 'AnonymousUserMixin' object has no attribute 'id'
How can I fix it? @inclusive-coding-bot
Beta Was this translation helpful? Give feedback.
All reactions