Bug description
I was performing some exercise on the export and import of dashboards and databases. First, I exported the database and removed the database from the database connection. Then, when I try to import the database using the same zip file, I get the following error:.
Same goes for the dashboard as well:
How to reproduce the bug
- Export a dashboard.
- Delete the dashboard.
- Try importing it.
- Same for the database.
Screenshots/recordings
Database error:
Dashboard error:
Superset version
4.0.2
Python version
3.9
Node version
16
Browser
Chrome
Additional context
No response
Checklist
- [ ] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [ ] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [ ] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Comment From: dosubot[bot]
I found some similar issues and discussions that might help you resolve the import errors you're encountering:
- Similar Issues and Discussions:
- Dashboard Import Error: An error occurred while importing dashboard: Error importing dashboard Please re-export your file and try importing again superset [1].
- Import is not working: An error occurred while importing dashboard: Import dashboard failed for an unknown reason [2].
-
Dashboard Import Error: An error occurred while importing dashboard: Error importing dashboard Please re-export your file and try importing again superset [3].
-
Suggested Solutions:
-
Downgrade to Version 4.0.0: Some users have reported that downgrading to version 4.0.0 resolved their import issues:
bash export TAG=4.0.0 docker compose -f docker-compose-image-tag.yml up
You can find more details and example dashboards in this issue [2]. -
Check and Fix YAML Files: If the error is related to incorrect values in the
template_params
parameter, you can manually fix the exported YAML files:- Unzip the exported file.
- Search for the
template_params
field in the YAML files and replace''
withnull
. - Recompress the directory and try importing again. Detailed steps can be found in this issue [4].
-
Ensure Correct Folder Structure: Make sure the folder structure in the ZIP file is correct. The root should contain directories like
Databases
andDatasets
. More details are available in this issue [5]. -
Import Request Structure: Ensure that your import request is correctly formatted and includes all necessary information. The import endpoint expects a multipart/form-data request with the following fields:
formData
: The uploaded file (ZIP or JSON).passwords
: A JSON map of passwords for each featured database in the ZIP file.overwrite
: A boolean indicating whether to overwrite existing dashboards.ssh_tunnel_passwords
: A JSON map of passwords for each SSH tunnel associated with a featured database in the ZIP file.ssh_tunnel_private_keys
: A JSON map of private keys for each SSH tunnel associated with a featured database in the ZIP file.
Example: ```python import requests
url = "http://your-superset-instance/api/v1/dashboard/import/" files = { 'formData': ('dashboard.zip', open('path/to/your/dashboard.zip', 'rb')), } data = { 'passwords': '{"databases/MyDatabase.yaml": "my_password"}', 'overwrite': 'true', 'ssh_tunnel_passwords': '{"databases/MyDatabase.yaml": "my_ssh_password"}', 'ssh_tunnel_private_keys': '{"databases/MyDatabase.yaml": "my_private_key"}', }
response = requests.post(url, files=files, data=data) print(response.status_code) print(response.json()) ``` Ensure that the paths and passwords in the JSON maps match the structure and contents of your ZIP file [6][7].
- Permissions: Ensure that the user performing the import has the "can_write" permission on the "Database" resource. Without this permission, the import will fail if the database does not already exist [8].
These steps should help you troubleshoot and resolve the import errors you're facing.
To continue talking to Dosu, mention @dosu.
Comment From: fisjac
What type of database were you attempting to import?
Comment From: rusackas
Also curious if you see any more error logs/stacktraces ont the frontend or in the server logs.
Comment From: JatinVenkatesh
What type of database were you attempting to import?
PostgreSQL
Comment From: JatinVenkatesh
Also curious if you see any more error logs/stacktraces ont the frontend or in the server logs.
2024-09-30 10:11:53,610:INFO:werkzeug:127.0.0.1 - - [30/Sep/2024 10:11:53] "GET /health HTTP/1.1" 200 - 2024-09-30 15:42:00 Command failed validation 2024-09-30 15:42:00 2024-09-30 10:12:00,113:INFO:superset.commands.dashboard.importers.dispatcher:Command failed validation 2024-09-30 15:42:00 CommandException 2024-09-30 15:42:00 Traceback (most recent call last): 2024-09-30 15:42:00 File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request 2024-09-30 15:42:00 rv = self.dispatch_request() 2024-09-30 15:42:00 File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request 2024-09-30 15:42:00 return self.ensure_sync(self.view_functions[rule.endpoint])(view_args) 2024-09-30 15:42:00 File "/usr/local/lib/python3.10/site-packages/flask_appbuilder/security/decorators.py", line 95, in wraps 2024-09-30 15:42:00 return f(self, *args, kwargs) 2024-09-30 15:42:00 File "/app/superset/views/base_api.py", line 127, in wraps 2024-09-30 15:42:00 raise ex 2024-09-30 15:42:00 File "/app/superset/views/base_api.py", line 121, in wraps 2024-09-30 15:42:00 duration, response = time_function(f, self, args, kwargs) 2024-09-30 15:42:00 File "/app/superset/utils/core.py", line 1470, in time_function 2024-09-30 15:42:00 response = func(args, kwargs) 2024-09-30 15:42:00 File "/app/superset/utils/log.py", line 255, in wrapper 2024-09-30 15:42:00 value = f(*args, kwargs) 2024-09-30 15:42:00 File "/app/superset/views/base_api.py", line 108, in wraps 2024-09-30 15:42:00 return f(self, args, kwargs) 2024-09-30 15:42:00 File "/app/superset/dashboards/api.py", line 1135, in import_ 2024-09-30 15:42:00 command.run() 2024-09-30 15:42:00 File "/app/superset/commands/dashboard/importers/dispatcher.py", line 64, in run 2024-09-30 15:42:00 raise exc 2024-09-30 15:42:00 File "/app/superset/commands/dashboard/importers/dispatcher.py", line 57, in run 2024-09-30 15:42:00 command.run() 2024-09-30 15:42:00 File "/app/superset/commands/importers/v1/init.py", line 71, in run 2024-09-30 15:42:00 self.validate() 2024-09-30 15:42:00 File "/app/superset/commands/importers/v1/init.py", line 109, in validate 2024-09-30 15:42:00 raise CommandInvalidError( 2024-09-30 15:42:00 superset.commands.exceptions.CommandInvalidError: Error importing dashboard 2024-09-30 15:42:00 2024-09-30 10:12:00,114:WARNING:superset.views.base:CommandException 2024-09-30 15:42:00 Traceback (most recent call last): 2024-09-30 15:42:00 File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request 2024-09-30 15:42:00 rv = self.dispatch_request() 2024-09-30 15:42:00 File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request 2024-09-30 15:42:00 return self.ensure_sync(self.view_functions[rule.endpoint])(view_args) 2024-09-30 15:42:00 File "/usr/local/lib/python3.10/site-packages/flask_appbuilder/security/decorators.py", line 95, in wraps 2024-09-30 15:42:00 return f(self, args, kwargs) 2024-09-30 15:42:00 File "/app/superset/views/base_api.py", line 127, in wraps 2024-09-30 15:42:00 raise ex 2024-09-30 15:42:00 File "/app/superset/views/base_api.py", line 121, in wraps 2024-09-30 15:42:00 duration, response = time_function(f, self, *args, kwargs) 2024-09-30 15:42:00 File "/app/superset/utils/core.py", line 1470, in time_function 2024-09-30 15:42:00 response = func(args, kwargs) 2024-09-30 15:42:00 File "/app/superset/utils/log.py", line 255, in wrapper 2024-09-30 15:42:00 value = f(args, kwargs) 2024-09-30 15:42:00 File "/app/superset/views/base_api.py", line 108, in wraps 2024-09-30 15:42:00 return f(self, *args, kwargs) 2024-09-30 15:42:00 File "/app/superset/dashboards/api.py", line 1135, in import_ 2024-09-30 15:42:00 command.run() 2024-09-30 15:42:00 File "/app/superset/commands/dashboard/importers/dispatcher.py", line 64, in run 2024-09-30 15:42:00 raise exc 2024-09-30 15:42:00 File "/app/superset/commands/dashboard/importers/dispatcher.py", line 57, in run 2024-09-30 15:42:00 command.run() 2024-09-30 15:42:00 File "/app/superset/commands/importers/v1/init.py", line 71, in run 2024-09-30 15:42:00 self.validate() 2024-09-30 15:42:00 File "/app/superset/commands/importers/v1/init.py", line 109, in validate 2024-09-30 15:42:00 raise CommandInvalidError( 2024-09-30 15:42:00 superset.commands.exceptions.CommandInvalidError: Error importing dashboard 2024-09-30 15:42:00 2024-09-30 10:12:00,123:INFO:werkzeug:172.18.0.1 - - [30/Sep/2024 10:12:00] "POST /api/v1/dashboard/import/ HTTP/1.1" 422 -
Comment From: rad-pat
Also experiencing the same issue and server Traceback
Comment From: rad-pat
@JatinVenkatesh - Use developer tools to inspect the response from the import/
request.
In my case the response looked like this, so I was able to debug and fix:
{
"errors": [
{
"message": "Error importing dashboard",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "warning",
"extra": {
"datasets/ACME1/ACME_RPT.yaml": {
"catalog": [
"Unknown field."
]
},
"issue_codes": [
{
"code": 1010,
"message": "Issue 1010 - Superset encountered an error while running a command."
}
]
}
}
]
}
Comment From: JatinVenkatesh
@JatinVenkatesh - Use developer tools to inspect the response from the
import/
request. In my case the response looked like this, so I was able to debug and fix:
{ "errors": [ { "message": "Error importing dashboard", "error_type": "GENERIC_COMMAND_ERROR", "level": "warning", "extra": { "datasets/ACME1/ACME_RPT.yaml": { "catalog": [ "Unknown field." ] }, "issue_codes": [ { "code": 1010, "message": "Issue 1010 - Superset encountered an error while running a command." } ] } } ] }
Ok, thank you will check that
Comment From: fisjac
I'm working on a PR to fix what I believe is the same issue. Linking for convenience. https://github.com/apache/superset/pull/30503
Comment From: rusackas
This has been silent for quite some time. I'm assuming the linked PR resolved the issue, but it just never got closed here. Let us know if anyone is still facing this in 4.1.1./5.0.0
Comment From: devikaaaa33
Hi @rusackas , I am facing same issue in version 4.1.1
Comment From: hi-im-mike
@rusackas @devikaaaa33
I am running 4 superset instances against 4 separate databases. Though I mainly develop in 1 environment; dashboards, charts, and datasets are the same across all instances. When importing my changes from develop to the other 3 instances via the UI, and the password box opened, I needed to provide the password (and whitelisting/ensuring connection) to my develop db.
Is there a way we can have a database selection form when importing these dashboards? Or at least allow importing if the password does not match/db connection is unavailable during import? Would be a massive help.
Importing via the CLI was no dice either (though I did not try after realizing this).
Comment From: BrunoBonacci
I'm running 4.1.1 and getting the same error
{
"errors": [
{
"message": "Import dashboard failed for an unknown reason",
"error_type": "GENERIC_COMMAND_ERROR",
"level": "error",
"extra": {
"issue_codes": [
{
"code": 1010,
"message": "Issue 1010 - Superset encountered an error while running a command."
}
]
}
}
]
}
Comment From: brantian
@rusackas Still facing same issue in version 4.1.2