Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashboard Import error #30383

Open
3 tasks
JatinVenkatesh opened this issue Sep 25, 2024 · 9 comments
Open
3 tasks

Dashboard Import error #30383

JatinVenkatesh opened this issue Sep 25, 2024 · 9 comments
Labels
dashboard:import Related to importing dashboards data Namespace | Anything related to data, including databases configurations, datasets, etc.

Comments

@JatinVenkatesh
Copy link

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:.
image

Same goes for the dashboard as well:
image

How to reproduce the bug

  1. Export a dashboard.
  2. Delete the dashboard.
  3. Try importing it.
  4. Same for the database.

Screenshots/recordings

Database error:
image

Dashboard error:
image

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.
@dosubot dosubot bot added dashboard:import Related to importing dashboards data Namespace | Anything related to data, including databases configurations, datasets, etc. labels Sep 25, 2024
Copy link

dosubot bot commented Sep 25, 2024

I found some similar issues and discussions that might help you resolve the import errors you're encountering:

  1. Similar Issues and Discussions:

  2. Suggested Solutions:

    • Downgrade to Version 4.0.0: Some users have reported that downgrading to version 4.0.0 resolved their import issues:

      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 '' with null.
      • 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 and Datasets. More details are available in this issue [5].

  3. 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:

    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].

  4. 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.

@fisjac
Copy link
Contributor

fisjac commented Sep 27, 2024

What type of database were you attempting to import?

@rusackas
Copy link
Member

Also curious if you see any more error logs/stacktraces ont the frontend or in the server logs.

@JatinVenkatesh
Copy link
Author

What type of database were you attempting to import?

PostgreSQL

@JatinVenkatesh
Copy link
Author

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 -

@rad-pat
Copy link

rad-pat commented Oct 2, 2024

Also experiencing the same issue and server Traceback

@rad-pat
Copy link

rad-pat commented Oct 2, 2024

@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."
                    }
                ]
            }
        }
    ]
}

@JatinVenkatesh
Copy link
Author

@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

@fisjac
Copy link
Contributor

fisjac commented Oct 3, 2024

I'm working on a PR to fix what I believe is the same issue. Linking for convenience.
#30503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dashboard:import Related to importing dashboards data Namespace | Anything related to data, including databases configurations, datasets, etc.
Projects
None yet
Development

No branches or pull requests

4 participants