Ahmed Saleh
Ahmed Saleh

Reputation: 25

Apache Superset importing using CLI issues

I'm running apache superset instance using docker image , the UI is working fine and I've managed to create datasource and a dashboard then I exported it as a zip file. my issue is whenever I tried to import the dashboards (or the database) using the superset cli superset import-dashboards -p myDashboard.zip i get the following exceptions

root@5be86760ec2a:/app# superset import-dashboards -p dash1.zip
Loaded your LOCAL configuration at [/app/docker/pythonpath_dev/superset_config.py]
logging was configured successfully
2023-10-23 08:39:13,044:INFO:superset.utils.logging_configurator:logging was configured successfully
2023-10-23 08:39:13,048:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
We haven't found any Content Security Policy (CSP) defined in the configurations. Please make sure to configure CSP using the TALISMAN_ENABLED and TALISMAN_CONFIG keys or any other external software. Failing to configure CSP have serious security implications. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP for more information. You can disable this warning using the CONTENT_SECURITY_POLICY_WARNING key.
2023-10-23 08:39:13,050:WARNING:superset.initialization:We haven't found any Content Security Policy (CSP) defined in the configurations. Please make sure to configure CSP using the TALISMAN_ENABLED and TALISMAN_CONFIG keys or any other external software. Failing to configure CSP have serious security implications. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP for more information. You can disable this warning using the CONTENT_SECURITY_POLICY_WARNING key.
/usr/local/lib/python3.9/site-packages/flask_limiter/extension.py:293: UserWarning: Using the in-memory storage for tracking rate limits as no storage was explicitly specified. This is not recommended for production use. See: https://flask-limiter.readthedocs.io#configuring-a-storage-backend for documentation about configuring the storage backend.
  warnings.warn(
/app/superset/commands/importers/v1/utils.py:113: SAWarning: TypeDecorator EncryptedType() will not produce a cache key because the ``cache_ok`` attribute is not set to True.  This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions.  Set this attribute to True if this type object's state is safe to use in a cache key, or False to disable this warning. (Background on this error at: https://sqlalche.me/e/14/cprf)
  for uuid, password in db.session.query(Database.uuid, Database.password).all()
/app/superset/commands/importers/v1/utils.py:118: SAWarning: TypeDecorator EncryptedType() will not produce a cache key because the ``cache_ok`` attribute is not set to True.  This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions.  Set this attribute to True if this type object's state is safe to use in a cache key, or False to disable this warning. (Background on this error at: https://sqlalche.me/e/14/cprf)
  for uuid, password in db.session.query(SSHTunnel.uuid, SSHTunnel.password).all()
/app/superset/commands/importers/v1/utils.py:123: SAWarning: TypeDecorator EncryptedType() will not produce a cache key because the ``cache_ok`` attribute is not set to True.  This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions.  Set this attribute to True if this type object's state is safe to use in a cache key, or False to disable this warning. (Background on this error at: https://sqlalche.me/e/14/cprf)
  for uuid, private_key in db.session.query(
/app/superset/commands/importers/v1/utils.py:130: SAWarning: TypeDecorator EncryptedType() will not produce a cache key because the ``cache_ok`` attribute is not set to True.  This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions.  Set this attribute to True if this type object's state is safe to use in a cache key, or False to disable this warning. (Background on this error at: https://sqlalche.me/e/14/cprf)
  for uuid, private_key_password in db.session.query(
Error running import command
Traceback (most recent call last):
  File "/app/superset/commands/importers/v1/__init__.py", line 77, in run
    self._import(db.session, self._configs, self.overwrite)
  File "/app/superset/dashboards/commands/importers/v1/__init__.py", line 89, in _import
    database = import_database(session, config, overwrite=False)
  File "/app/superset/databases/commands/importers/v1/utils.py", line 38, in import_database
    can_write = ignore_permissions or security_manager.can_access(
  File "/app/superset/security/manager.py", line 327, in can_access
    user = g.user
  File "/usr/local/lib/python3.9/site-packages/flask/ctx.py", line 52, in __getattr__
    raise AttributeError(name) from None
AttributeError: user

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/superset/dashboards/commands/importers/dispatcher.py", line 57, in run
    command.run()
  File "/app/superset/commands/importers/v1/__init__.py", line 84, in run
    raise self.import_error() from ex
superset.dashboards.commands.exceptions.DashboardImportError: Import dashboard failed for an unknown reason
2023-10-23 08:39:14,571:ERROR:superset.dashboards.commands.importers.dispatcher:Error running import command
Traceback (most recent call last):
  File "/app/superset/commands/importers/v1/__init__.py", line 77, in run
    self._import(db.session, self._configs, self.overwrite)
  File "/app/superset/dashboards/commands/importers/v1/__init__.py", line 89, in _import
    database = import_database(session, config, overwrite=False)
  File "/app/superset/databases/commands/importers/v1/utils.py", line 38, in import_database
    can_write = ignore_permissions or security_manager.can_access(
  File "/app/superset/security/manager.py", line 327, in can_access
    user = g.user
  File "/usr/local/lib/python3.9/site-packages/flask/ctx.py", line 52, in __getattr__
    raise AttributeError(name) from None
AttributeError: user

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/superset/dashboards/commands/importers/dispatcher.py", line 57, in run
    command.run()
  File "/app/superset/commands/importers/v1/__init__.py", line 84, in run
    raise self.import_error() from ex
superset.dashboards.commands.exceptions.DashboardImportError: Import dashboard failed for an unknown reason
There was an error when importing the dashboards(s), please check the exception traceback in the log
Traceback (most recent call last):
  File "/app/superset/commands/importers/v1/__init__.py", line 77, in run
    self._import(db.session, self._configs, self.overwrite)
  File "/app/superset/dashboards/commands/importers/v1/__init__.py", line 89, in _import
    database = import_database(session, config, overwrite=False)
  File "/app/superset/databases/commands/importers/v1/utils.py", line 38, in import_database
    can_write = ignore_permissions or security_manager.can_access(
  File "/app/superset/security/manager.py", line 327, in can_access
    user = g.user
  File "/usr/local/lib/python3.9/site-packages/flask/ctx.py", line 52, in __getattr__
    raise AttributeError(name) from None
AttributeError: user

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/superset/cli/importexport.py", line 161, in import_dashboards
    ImportDashboardsCommand(contents, overwrite=True).run()
  File "/app/superset/dashboards/commands/importers/dispatcher.py", line 68, in run
    raise exc
  File "/app/superset/dashboards/commands/importers/dispatcher.py", line 57, in run
    command.run()
  File "/app/superset/commands/importers/v1/__init__.py", line 84, in run
    raise self.import_error() from ex
superset.dashboards.commands.exceptions.DashboardImportError: Import dashboard failed for an unknown reason
2023-10-23 08:39:14,576:ERROR:superset.cli.importexport:There was an error when importing the dashboards(s), please check the exception traceback in the log
Traceback (most recent call last):
  File "/app/superset/commands/importers/v1/__init__.py", line 77, in run
    self._import(db.session, self._configs, self.overwrite)
  File "/app/superset/dashboards/commands/importers/v1/__init__.py", line 89, in _import
    database = import_database(session, config, overwrite=False)
  File "/app/superset/databases/commands/importers/v1/utils.py", line 38, in import_database
    can_write = ignore_permissions or security_manager.can_access(
  File "/app/superset/security/manager.py", line 327, in can_access
    user = g.user
  File "/usr/local/lib/python3.9/site-packages/flask/ctx.py", line 52, in __getattr__
    raise AttributeError(name) from None
AttributeError: user

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/superset/cli/importexport.py", line 161, in import_dashboards
    ImportDashboardsCommand(contents, overwrite=True).run()
  File "/app/superset/dashboards/commands/importers/dispatcher.py", line 68, in run
    raise exc
  File "/app/superset/dashboards/commands/importers/dispatcher.py", line 57, in run
    command.run()
  File "/app/superset/commands/importers/v1/__init__.py", line 84, in run
    raise self.import_error() from ex
superset.dashboards.commands.exceptions.DashboardImportError: Import dashboard failed for an unknown reason

the same issue happened when trying to import datasources

I tried to import same exact files using the superset UI , it works fine. also tried to change the database url in the exported files by providing the actual db password , still the same.

Upvotes: 2

Views: 1970

Answers (1)

martnaum
martnaum

Reputation: 46

Had the same issue. You can specify a user for the import processes as written below. That solved my problem:

superset import-dashboards -p dashboards.zip -u admin

I also discovered this in the CLI help. Of course only after I had it up and running 🤦‍♂️:

Usage: superset import-dashboards [OPTIONS]

  Import dashboards from ZIP file

Options:
  -p, --path TEXT      Path to a single ZIP file
  -u, --username TEXT  Specify the user name to assign dashboards to
  --help               Show this message and exit.

Upvotes: 3

Related Questions