Flask g.user is None
See original GitHub issueI ran superset export-dashboards
on a fresh install of latest master. I see the same error for superset export-datasources
.
Expected results
Expect command to export resources.
Actual results
There was an error when exporting the dashboards, please check the exception traceback in the log
Traceback (most recent call last):
File "/home/fedora/superset/repo/superset/superset/cli.py", line 269, in export_dashboards
for file_name, file_content in ExportDashboardsCommand(
File "/home/fedora/superset/repo/superset/superset/commands/export.py", line 50, in run
self.validate()
File "/home/fedora/superset/repo/superset/superset/commands/export.py", line 67, in validate
self._models = self.dao.find_by_ids(self.model_ids)
File "/home/fedora/superset/repo/superset/superset/dao/base.py", line 74, in find_by_ids
query = cls.base_filter( # pylint: disable=not-callable
File "/home/fedora/superset/repo/superset/superset/dashboards/filters.py", line 73, in apply
if is_user_admin():
File "/home/fedora/superset/repo/superset/superset/views/base.py", line 258, in is_user_admin
user_roles = [role.name.lower() for role in list(get_user_roles())]
File "/home/fedora/superset/repo/superset/superset/views/base.py", line 251, in get_user_roles
if g.user.is_anonymous:
AttributeError: 'NoneType' object has no attribute 'is_anonymous'
2021-05-12 11:34:09,092:ERROR:superset.cli:There was an error when exporting the dashboards, please check the exception traceback in the log
Traceback (most recent call last):
File "/home/fedora/superset/repo/superset/superset/cli.py", line 269, in export_dashboards
for file_name, file_content in ExportDashboardsCommand(
File "/home/fedora/superset/repo/superset/superset/commands/export.py", line 50, in run
self.validate()
File "/home/fedora/superset/repo/superset/superset/commands/export.py", line 67, in validate
self._models = self.dao.find_by_ids(self.model_ids)
File "/home/fedora/superset/repo/superset/superset/dao/base.py", line 74, in find_by_ids
query = cls.base_filter( # pylint: disable=not-callable
File "/home/fedora/superset/repo/superset/superset/dashboards/filters.py", line 73, in apply
if is_user_admin():
File "/home/fedora/superset/repo/superset/superset/views/base.py", line 258, in is_user_admin
user_roles = [role.name.lower() for role in list(get_user_roles())]
File "/home/fedora/superset/repo/superset/superset/views/base.py", line 251, in get_user_roles
if g.user.is_anonymous:
AttributeError: 'NoneType' object has no attribute 'is_anonymous'
How to reproduce the bug
- Install Superset latest master in editable mode
- Run
superset export-dashboards
Environment
(please complete the following information):
- superset version: 0.999.0dev
- python version: Python 3.8.7
- node.js version: v14.16.0
Checklist
Make sure to follow these steps before submitting your issue - thank you!
- I have checked the superset logs for python stacktraces and included it here as text if there are any.
- I have reproduced the issue with at least the latest released version of superset.
- I have checked the issue tracker for the same issue and I haven’t found one similar.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
How to use g.user global in flask
As I understand the g variable in Flask, it should provide me with a global place to stash data like holding the current...
Read more >Python flask.g.user() Examples
This page shows Python examples of flask.g.user. ... def login(): if g.user is not None: return redirect(url_for('index')) form = LoginForm(request.form) if ...
Read more >flask.globals g Example Code
Python example code that shows how to use the g callable from the flask.globals module of the Flask project.
Read more >flask.g.user Example
Learn how to use python api flask.g.user. ... @app.before_request def before_request(): flask.g.user = None if "openid" in flask.session: username ...
Read more >What is g in python flask?
g is an object provided by Flask. It is a global namespace for holding any data you want during a single app context....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This happens if you run
superset export-dashboards
without having created an admin user withsuperset fab create-admin
Closing as I am now able to do
superset export-dashboards
followed bysuperset import-dashboards
, as well assuperset export-datasources
followed bysuperset import-datasources
, on latest master without errors.