superset icon indicating copy to clipboard operation
superset copied to clipboard

Import is not working: An error occurred while importing dashboard: Import dashboard failed for an unknown reason

Open Narendra678 opened this issue 2 years ago • 25 comments

Hi Team,

I am trying to import dashboard getting below error. An error occurred while importing dashboard: Import dashboard failed for an unknown reason

Note: when try to import i can see dataset added when i try to import chart it is working. I am able to import other reports

Regards, Naren

Narendra678 avatar Mar 16 '22 18:03 Narendra678

Hello! Could you take some screenshots of what you are experiencing?

AAfghahi avatar Mar 17 '22 20:03 AAfghahi

image

Narendra678 avatar Mar 18 '22 06:03 Narendra678

2022-03-18 07:29:47 default[1-3-1qa] Error running import command 2022-03-18 07:29:47 default[1-3-1qa] Traceback (most recent call last): File "/workspace/superset/commands/importers/v1/init.py", line 67, in run self._import(db.session, self._configs, self.overwrite) File "/workspace/superset/dashboards/commands/importers/v1/init.py", line 126, in _import config = update_id_refs(config, chart_ids, dataset_info) File "/workspace/superset/dashboards/commands/importers/v1/utils.py", line 85, in update_id_refs for old_id, columns in metadata["filter_scopes"].items() File "/workspace/superset/dashboards/commands/importers/v1/utils.py", line 85, in for old_id, columns in metadata["filter_scopes"].items() KeyError: 580 2022-03-18 07:29:47 default[1-3-1qa] 2022-03-18 07:29:47 default[1-3-1qa] During handling of the above exception, another exception occurred: 2022-03-18 07:29:47 default[1-3-1qa] 2022-03-18 07:29:47 default[1-3-1qa] Traceback (most recent call last): File "/workspace/superset/dashboards/commands/importers/dispatcher.py", line 58, in run command.run() File "/workspace/superset/commands/importers/v1/init.py", line 71, in run raise self.import_error() superset.dashboards.commands.exceptions.DashboardImportError: Import dashboard failed for an unknown reason 2022-03-18 07:29:47 default[1-3-1qa] 2022-03-18 07:29:47,754:ERROR:superset.dashboards.commands.importers.dispatcher:Error running import command 2022-03-18 07:29:47 default[1-3-1qa] Traceback (most recent call last): File "/workspace/superset/commands/importers/v1/init.py", line 67, in run self._import(db.session, self._configs, self.overwrite) File "/workspace/superset/dashboards/commands/importers/v1/init.py", line 126, in _import config = update_id_refs(config, chart_ids, dataset_info) File "/workspace/superset/dashboards/commands/importers/v1/utils.py", line 85, in update_id_refs for old_id, columns in metadata["filter_scopes"].items() File "/workspace/superset/dashboards/commands/importers/v1/utils.py", line 85, in for old_id, columns in metadata["filter_scopes"].items() KeyError: 580 2022-03-18 07:29:47 default[1-3-1qa] 2022-03-18 07:29:47 default[1-3-1qa] During handling of the above exception, another exception occurred: 2022-03-18 07:29:47 default[1-3-1qa] 2022-03-18 07:29:47 default[1-3-1qa] Traceback (most recent call last): File "/workspace/superset/dashboards/commands/importers/dispatcher.py", line 58, in run command.run() File "/workspace/superset/commands/importers/v1/init.py", line 71, in run raise self.import_error() superset.dashboards.commands.exceptions.DashboardImportError: Import dashboard failed for an unknown reason 2022-03-18 07:29:47 default[1-3-1qa] Import dashboard failed for an unknown reason 2022-03-18 07:29:47 default[1-3-1qa] 2022-03-18 07:29:47,755:WARNING:superset.views.base:Import dashboard failed for an unknown reason

Narendra678 avatar Mar 18 '22 07:03 Narendra678

So you get this toast before you upload a dashboard or after you put in a dashboard and then press import.

AAfghahi avatar Mar 18 '22 15:03 AAfghahi

Export(Download)working in first environment and then importing(Upload) in to second environment.

I am getting error in "then importing(Upload) in to second environment."

Narendra678 avatar Mar 18 '22 16:03 Narendra678

I am facing the same issue... but this happens only in case of multiple datasets

nerdyslacker avatar Mar 21 '22 14:03 nerdyslacker

ok makes sense, I will try to replicate this bug today. Could you tell me what engines you were running and if it is agnostic of the chart/viz types involved.

AAfghahi avatar Mar 21 '22 14:03 AAfghahi

ok makes sense, I will try to replicate this bug today. Could you tell me what engines you were running and if it is agnostic of the chart/viz types involved.

Below is the latest error logs. ERROR:root:'NoneType' object has no attribute 'uuid'

2022-03-22 10:14:04 default[1-3-1noimc] "GET /api/v1/dashboard/export/?q=!(14)&token=zVVSihwxp HTTP/1.1" 500 2022-03-22 10:14:05 default[1-3-1noimc] 2022-03-22 10:14:05,189:ERROR:root:'NoneType' object has no attribute 'uuid' 2022-03-22 10:14:05 default[1-3-1noimc] Traceback (most recent call last): File "/layers/google.python.pip/pip/lib/python3.7/site-packages/flask_appbuilder/api/init.py", line 85, in wraps return f(self, *args, **kwargs) File "/workspace/superset/views/base_api.py", line 85, in wraps raise ex File "/workspace/superset/views/base_api.py", line 82, in wraps duration, response = time_function(f, self, *args, **kwargs) File "/workspace/superset/utils/core.py", line 1429, in time_function response = func(*args, **kwargs) File "/layers/google.python.pip/pip/lib/python3.7/site-packages/flask_appbuilder/api/init.py", line 155, in wraps return f(self, *args, **kwargs) File "/workspace/superset/utils/log.py", line 241, in wrapper value = f(*args, **kwargs) File "/workspace/superset/dashboards/api.py", line 718, in export requested_ids File "/workspace/superset/commands/export.py", line 61, in run for file_name, file_content in self._export(model): File "/workspace/superset/dashboards/commands/export.py", line 140, in _export target["datasetUuid"] = str(dataset.uuid) AttributeError: 'NoneType' object has no attribute 'uuid' 2022-03-22 10:14:44 default[1-3-1noimc] "GET /dashboard/list/?pageIndex=0&sortColumn=changed_on_delta_humanized&sortOrder=desc&viewMode=table HTTP/1.1" 200 2022-03-22 10:14:46 default[1-3-1noimc] "GET /api/v1/dashboard/related/created_by?q=() HTTP/1.1" 200 2022-03-22 10:14:46 default[1-3-1noimc] "GET /api/v1/dashboard/related/owners?q=() HTTP/1.1" 200 2022-03-22 10:14:47 default[1-3-1noimc] "GET /api/v1/dashboard/?q=(order_column:changed_on_delta_humanized,order_direction:desc,page:0,page_size:25) HTTP/1.1" 200 2022-03-22 10:14:48 default[1-3-1noimc] "GET /api/v1/dashboard/_info?q=(keys:!(permissions)) HTTP/1.1" 200 2022-03-22 10:14:48 default[1-3-1noimc] "GET /static/assets/images/favicon.png HTTP/1.1" 304 2022-03-22 10:14:48 default[1-3-1noimc] "GET /api/v1/dashboard/favorite_status/?q=!(47,50,52,48,41,55,10,29,14,59,56,6,53,51,46,11,42,43,45,33,19,44,40,38,20) HTTP/1.1" 200

Narendra678 avatar Mar 23 '22 12:03 Narendra678

I am having the same issue. I am getting the same error when trying to import even a single dataset. Importing a chart (when the linked dataset is exists) is not possible either.

smetirem avatar Apr 13 '22 08:04 smetirem

recreated report then it is working for me.

Narendra678 avatar Apr 14 '22 05:04 Narendra678

Hello, trying to import datasets via UI from dev env (superset 1.5.0) to a new hosts with 2.0.0rc2 Same error here

superset_app | 2022-07-08 21:14:09,879:INFO:superset.datasets.commands.importers.v0:Importing dataset from file 20220708_200853.yaml superset_app | Error running import command superset_app | Traceback (most recent call last): superset_app | File "/app/superset/datasets/commands/importers/dispatcher.py", line 57, in run superset_app | command.run() superset_app | File "/app/superset/datasets/commands/importers/v0.py", line 266, in run superset_app | params = json.loads(dataset["params"]) superset_app | KeyError: 'params' superset_app | 2022-07-08 21:14:09,880:ERROR:superset.datasets.commands.importers.dispatcher:Error running import command superset_app | Traceback (most recent call last): superset_app | File "/app/superset/datasets/commands/importers/dispatcher.py", line 57, in run superset_app | command.run() superset_app | File "/app/superset/datasets/commands/importers/v0.py", line 266, in run superset_app | params = json.loads(dataset["params"]) superset_app | KeyError: 'params' superset_app | 'params' superset_app | Traceback (most recent call last): superset_app | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request superset_app | rv = self.dispatch_request() superset_app | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request superset_app | return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) superset_app | File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/security/decorators.py", line 89, in wraps superset_app | return f(self, *args, **kwargs) superset_app | File "/app/superset/views/base_api.py", line 113, in wraps superset_app | raise ex superset_app | File "/app/superset/views/base_api.py", line 110, in wraps superset_app | duration, response = time_function(f, self, *args, **kwargs) superset_app | File "/app/superset/utils/core.py", line 1507, in time_function superset_app | response = func(*args, **kwargs) superset_app | File "/app/superset/utils/log.py", line 245, in wrapper superset_app | value = f(*args, **kwargs) superset_app | File "/app/superset/views/base_api.py", line 98, in wraps superset_app | return f(self, *args, **kwargs) superset_app | File "/app/superset/datasets/api.py", line 766, in import_ superset_app | command.run() superset_app | File "/app/superset/datasets/commands/importers/dispatcher.py", line 68, in run superset_app | raise exc superset_app | File "/app/superset/datasets/commands/importers/dispatcher.py", line 57, in run superset_app | command.run() superset_app | File "/app/superset/datasets/commands/importers/v0.py", line 266, in run superset_app | params = json.loads(dataset["params"]) superset_app | KeyError: 'params' superset_app | 2022-07-08 21:14:09,881:ERROR:superset.views.base:'params' superset_app | Traceback (most recent call last): superset_app | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request superset_app | rv = self.dispatch_request() superset_app | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request superset_app | return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) superset_app | File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/security/decorators.py", line 89, in wraps superset_app | return f(self, *args, **kwargs) superset_app | File "/app/superset/views/base_api.py", line 113, in wraps superset_app | raise ex superset_app | File "/app/superset/views/base_api.py", line 110, in wraps superset_app | duration, response = time_function(f, self, *args, **kwargs) superset_app | File "/app/superset/utils/core.py", line 1507, in time_function superset_app | response = func(*args, **kwargs) superset_app | File "/app/superset/utils/log.py", line 245, in wrapper superset_app | value = f(*args, **kwargs) superset_app | File "/app/superset/views/base_api.py", line 98, in wraps superset_app | return f(self, *args, **kwargs) superset_app | File "/app/superset/datasets/api.py", line 766, in import_ superset_app | command.run() superset_app | File "/app/superset/datasets/commands/importers/dispatcher.py", line 68, in run superset_app | raise exc superset_app | File "/app/superset/datasets/commands/importers/dispatcher.py", line 57, in run superset_app | command.run() superset_app | File "/app/superset/datasets/commands/importers/v0.py", line 266, in run superset_app | params = json.loads(dataset["params"]) superset_app | KeyError: 'params'

yiyux avatar Jul 08 '22 21:07 yiyux

Having the same issue here

lanzhenw avatar Jul 15 '22 16:07 lanzhenw

I had the same issue, but it worked when I imported the .zip file, instead of the individual .yaml file. I guess the error that is raised should be more clear about it.

javiermas avatar Jul 25 '22 15:07 javiermas

We are trying to build automation to promote dashboards between environments and we're also seeing dashboard import failures. Ours turned out to be due to the expanded_slices key that the importer couldn't handle, in our case it was pointing at a chart no longer part of the dashboard. No idea how it got there, maybe through the ui. Ultimately if we unzipped the dashboards, removed the key yq -i e 'del(.metadata.expanded_slices)' $f it would import.

This lead to this super hacky snippet in our pipeline, to unzip, remove expanded_slices, then reupload. Ultimately the right fix will be for the upload to either ignore or handle the expanded_slices field.

          cd assets/dashboards
          if [[ ! -f *.zip ]] ; then
            echo 'no dashboards marked for upload'
            exit
          fi
          unzip '*.zip'
          rm -rf *.zip
          # rm -rf ./*/databases
          ls
          yq --help
          yq --version
          for f in ./*/dashboards/*.yaml; do
            yq -i e 'del(.metadata.expanded_slices)' $f
          done
          for f in ./*/; do
              if [ -d "$f" ]; then
                  # Will not run if no directories are available
                  echo $f
                  zip -r "${f%/}.zip" "$f"
              fi

wulfuric avatar Sep 22 '22 21:09 wulfuric

same issue, simple export from dashboard and then using CLI to import fails, makes it hard to get devops and CI working.

terrancesnyder avatar Jul 29 '23 07:07 terrancesnyder

I am also seeing this issue when importing both charts and dashboards, I'm unclear on the precise cause (not much that is useful from the logs I can see).

I will note that I have a CI script that manages imports via the REST API and that has continued to work just fine. For anyone building automation around data/dashboard loading I would recommend that approach.

andy-clapson avatar Aug 30 '23 19:08 andy-clapson

@andy-clapson Could you share the script or the main parts of it with us too? Would be highly appreciated!

pyryjook avatar Sep 27 '23 13:09 pyryjook

Hey folks, I see this went silent around the time 3.0 came out. Is this still an issue?

rusackas avatar Mar 08 '24 03:03 rusackas

Hi @rusackas,

Actually I tested it with version 3.0.0 back then, and the problem was still there.

There was also some recent discussion regarding this in Slack: https://apache-superset.slack.com/archives/C015WAZL0KH/p1695889915182819

pyryjook avatar Mar 08 '24 06:03 pyryjook

Try now with 3.1, I wasn't able to even track DashboardImportError as it looks like a dead code now...

butuzov avatar Mar 26 '24 15:03 butuzov

I'm expericing the sam issue here

Davidkramer1999 avatar Mar 27 '24 06:03 Davidkramer1999

I'm experiencing the same issue while importing a single dataset. Getting error "An error occurred while importing dataset: Could not find a valid command to import file. Please re-export your file and try importing again"

malikvashu29 avatar Apr 09 '24 13:04 malikvashu29

Is anyone experiencing this able to make an example export to share here that we can troubleshoot with? I haven't been able to reproduce the issue. It seems like if you make a virtual dataset that generates the data as part of the query, you might be safe to share the export? CC @betodealmeida in case they have any idea how to troubleshoot/repro/fix this.

rusackas avatar Apr 09 '24 20:04 rusackas

@rusackas @betodealmeida i get the same issue in 4.0.0,how can i resolve it.

marituhone avatar Apr 25 '24 06:04 marituhone

Hi @rusackas , I was able to reproduce this today as well, from 1.3 to 4.0. Steps:

  1. Export multiple datasets (physical/virtual) from older version, this gives you an yaml file.
  2. Try importing that data sets on 4.0 superset.
  3. You see an error like this:
image
View Logs
Importing dataset from file 20240425_165955.yaml
2024-04-25 17:09:48,511:INFO:superset.commands.dataset.importers.v0:Importing dataset from file 20240425_165955.yaml
Error running import command
Traceback (most recent call last):
  File "/app/superset/commands/dataset/importers/dispatcher.py", line 57, in run
    command.run()
  File "/app/superset/commands/dataset/importers/v0.py", line 255, in run
    params = json.loads(dataset["params"])
KeyError: 'params'
2024-04-25 17:09:48,511:ERROR:superset.commands.dataset.importers.dispatcher:Error running import command
Traceback (most recent call last):
  File "/app/superset/commands/dataset/importers/dispatcher.py", line 57, in run
    command.run()
  File "/app/superset/commands/dataset/importers/v0.py", line 255, in run
    params = json.loads(dataset["params"])
KeyError: 'params'
'params'
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/usr/local/lib/python3.10/site-packages/flask_appbuilder/security/decorators.py", line 95, in wraps
    return f(self, *args, **kwargs)
  File "/app/superset/views/base_api.py", line 127, in wraps
    raise ex
  File "/app/superset/views/base_api.py", line 121, in wraps
    duration, response = time_function(f, self, *args, **kwargs)
  File "/app/superset/utils/core.py", line 1463, in time_function
    response = func(*args, **kwargs)
  File "/app/superset/utils/log.py", line 255, in wrapper
    value = f(*args, **kwargs)
  File "/app/superset/views/base_api.py", line 108, in wraps
    return f(self, *args, **kwargs)
  File "/app/superset/datasets/api.py", line 926, in import_
    command.run()
  File "/app/superset/commands/dataset/importers/dispatcher.py", line 68, in run
    raise exc
  File "/app/superset/commands/dataset/importers/dispatcher.py", line 57, in run
    command.run()
  File "/app/superset/commands/dataset/importers/v0.py", line 255, in run
    params = json.loads(dataset["params"])
KeyError: 'params'
2024-04-25 17:09:48,511:ERROR:superset.views.base:'params'
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/usr/local/lib/python3.10/site-packages/flask_appbuilder/security/decorators.py", line 95, in wraps
    return f(self, *args, **kwargs)
  File "/app/superset/views/base_api.py", line 127, in wraps
    raise ex
  File "/app/superset/views/base_api.py", line 121, in wraps
    duration, response = time_function(f, self, *args, **kwargs)
  File "/app/superset/utils/core.py", line 1463, in time_function
    response = func(*args, **kwargs)
  File "/app/superset/utils/log.py", line 255, in wrapper
    value = f(*args, **kwargs)
  File "/app/superset/views/base_api.py", line 108, in wraps
    return f(self, *args, **kwargs)
  File "/app/superset/datasets/api.py", line 926, in import_
    command.run()
  File "/app/superset/commands/dataset/importers/dispatcher.py", line 68, in run
    raise exc
  File "/app/superset/commands/dataset/importers/dispatcher.py", line 57, in run
    command.run()
  File "/app/superset/commands/dataset/importers/v0.py", line 255, in run
    params = json.loads(dataset["params"])
KeyError: 'params'

1yuv avatar Apr 25 '24 17:04 1yuv