apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
61.98k stars 13.59k forks source link

Dashboard Import error #30383

Open JatinVenkatesh opened 3 days ago

JatinVenkatesh commented 3 days ago

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

dosubot[bot] commented 3 days ago

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 commented 14 hours ago

What type of database were you attempting to import?

rusackas commented 13 hours ago

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