question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flask g.user is None

See original GitHub issue

I 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

  1. Install Superset latest master in editable mode
  2. 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:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
krsnik93commented, Jun 24, 2021

This happens if you run superset export-dashboards without having created an admin user with superset fab create-admin

0reactions
krsnik93commented, Jun 15, 2021

Closing as I am now able to do superset export-dashboards followed by superset import-dashboards, as well as superset export-datasources followed by superset import-datasources, on latest master without errors.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found