Bug description
I am trying to import databases, datasets, dashboards and chats using API calls. I am downloading theses from superset version 4.0.2 to 4.1.1 and getting error as "=== Importing database from /tmp/repo/databases/databases.zip === ERROR: Failed to import database from /tmp/repo/databases/databases.zip. HTTP response code: 422 Response body: {"errors": [{"message": "Could not find a valid command to import file", "error_type": "GENERIC_COMMAND_ERROR", "level": "warning", "extra": {"issue_codes": [{"code": 1010, "message": "Issue 1010 - Superset encountered an error while running a command."}]}}]}--- === Importing dataset from /tmp/repo/datasets/datasets.zip === ERROR: Failed to import dataset from /tmp/repo/datasets/datasets.zip. HTTP response code: 422 Response body: {"errors": [{"message": "Could not find a valid command to import file", "error_type": "GENERIC_COMMAND_ERROR", "level": "warning", "extra": {"issue_codes": [{"code": 1010, "message": "Issue 1010 - Superset encountered an error while running a command."}]}}]}--- === Importing chart from /tmp/repo/charts/charts.zip === ERROR: Failed to import chart from /tmp/repo/charts/charts.zip. HTTP response code: 422 Response body: {"errors": [{"message": "Could not find a valid command to import file", "error_type": "GENERIC_COMMAND_ERROR", "level": "warning", "extra": {"issue_codes": [{"code": 1010, "message": "Issue 1010 - Superset encountered an error while running a command."}]}}]}---"
Please let me know what folder structure I have to use for these assets
--- Import Databases ---
echo "---" echo "=== Importing database from $DB_ZIP ===" db_response=$(curl -k -s -w "%{http_code}" -b cookies.txt -o db_response_body.txt \ --url "https://$APP_PREFIX.$DOMAIN/api/v1/database/import/" \ --header 'accept: application/json' \ --header "Authorization: Bearer $ACCESS_TOKEN" \ --header 'content-type: multipart/form-data' \ --header "referer: https://$APP_PREFIX.$DOMAIN" \ --header "x-csrftoken: $CSRF_TOKEN" \ --form "formData=@$DB_ZIP" \ --form overwrite=true \ --form "passwords={\"databases/Reporting.yaml\": \"$DASHBOARD_DB_PASS\"}") if [ "$db_response" -eq 200 ]; then echo "Successfully imported database from $DB_ZIP." else echo "ERROR: Failed to import database from $DB_ZIP. HTTP response code: $db_response" echo "Response body:" cat db_response_body.txt
fi
--- Import Datasets ---
echo "---" echo "=== Importing dataset from $DATASET_ZIP ===" dataset_response=$(curl -k -s -w "%{http_code}" -b cookies.txt -o dataset_response_body.txt \ --url "https://$APP_PREFIX.$DOMAIN/api/v1/dataset/import/" \ --header 'accept: application/json' \ --header "Authorization: Bearer $ACCESS_TOKEN" \ --header 'content-type: multipart/form-data' \ --header "referer: https://$APP_PREFIX.$DOMAIN" \ --header "x-csrftoken: $CSRF_TOKEN" \ --form "formData=@$DATASET_ZIP" \ --form overwrite=true \ --form "passwords={\"databases/Reporting.yaml\": \"$DASHBOARD_DB_PASS\"}") if [ "$dataset_response" -eq 200 ]; then echo "Successfully imported dataset from $DATASET_ZIP." else echo "ERROR: Failed to import dataset from $DATASET_ZIP. HTTP response code: $dataset_response" echo "Response body:" cat dataset_response_body.txt
fi
--- Import Charts ---
echo "---" echo "=== Importing chart from $CHART_ZIP ===" chart_response=$(curl -k -s -w "%{http_code}" -b cookies.txt -o chart_response_body.txt \ --url "https://$APP_PREFIX.$DOMAIN/api/v1/chart/import/" \ --header 'accept: application/json' \ --header "Authorization: Bearer $ACCESS_TOKEN" \ --header 'content-type: multipart/form-data' \ --header "referer: https://$APP_PREFIX.$DOMAIN" \ --header "x-csrftoken: $CSRF_TOKEN" \ --form "formData=@$CHART_ZIP" \ --form overwrite=true \ --form "passwords={\"databases/Reporting.yaml\": \"$DASHBOARD_DB_PASS\"}") if [ "$chart_response" -eq 200 ]; then echo "Successfully imported chart from $CHART_ZIP." else echo "ERROR: Failed to import chart from $CHART_ZIP. HTTP response code: $chart_response" echo "Response body:" cat chart_response_body.txt
fi
--- Import Dashboards ---
echo "---" echo "=== Importing dashboard from $DASHBOARD_ZIP ===" dashboard_response=$(curl -k -s -w "%{http_code}" -b cookies.txt -o dashboard_response_body.txt \ --url "https://$APP_PREFIX.$DOMAIN/api/v1/dashboard/import/" \ --header 'accept: application/json' \ --header "Authorization: Bearer $ACCESS_TOKEN" \ --header 'content-type: multipart/form-data' \ --header "referer: https://$APP_PREFIX.$DOMAIN" \ --header "x-csrftoken: $CSRF_TOKEN" \ --form "formData=@$DASHBOARD_ZIP" \ --form overwrite=true \ --form "passwords={\"databases/Reporting.yaml\": \"$DASHBOARD_DB_PASS\"}") if [ "$dashboard_response" -eq 200 ]; then echo "Successfully imported dashboard from $DASHBOARD_ZIP."
Screenshots/recordings
Superset version
4.1.2
Python version
3.10
Node version
16
Browser
Not applicable
Additional context
No response
Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] 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]
The HTTP 422 and "Could not find a valid command to import file" errors usually mean the ZIP file structure or the form field names in your API request don't match what Superset expects.
For each asset type (databases, datasets, charts, dashboards), the ZIP should have a top-level folder named exactly as the asset type, containing the relevant YAML files. For example, for a database import, your ZIP should look like:
databases/
MyDatabase.yaml
For datasets:
datasets/
MyDataset.yaml
databases/
MyDatabase.yaml
For charts:
charts/
MyChart.yaml
datasets/
MyDataset.yaml
databases/
MyDatabase.yaml
For dashboards:
dashboards/
MyDashboard.yaml
charts/
MyChart.yaml
datasets/
MyDataset.yaml
databases/
MyDatabase.yaml
Each asset references its dependencies, so you must include all related YAMLs in the correct folders inside the ZIP. If you only include a single YAML or the folder name doesn't match, you'll get the error you're seeing. The API expects the form field to be named formData
for these endpoints, which you are already using correctly.
There were no breaking changes in the import structure between 4.0.2 and 4.1.2, so this is almost certainly a structural issue with the ZIP contents or folder names, not a version problem. More details and examples are in the official docs and the import API code.
If you want to import only a subset of assets and let Superset use existing dependencies, you can try the sparse
option (if available in your version), but by default, all dependencies must be present in the ZIP for a successful import.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
Comment From: devikaaaa33
@dosu, Does each zip folder require a metadata.yaml?
Comment From: dosubot[bot]
No, you do not need a metadata.yaml in each subfolder. Superset requires a single metadata.yaml file at the root of the ZIP file you upload for import. This file is mandatory for the import process to recognize and validate the bundle—if it's missing or not at the root, you'll get errors like the one you saw. The subfolders (like charts, datasets, databases, dashboards) just need to contain the relevant YAML files for each asset type; only the root needs the metadata.yaml file with the correct version field (e.g., version: 1.0.0) source source.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
Comment From: devikaaaa33
Hi @dosu, I am still getting same error even though I followed provided structure. I am using version 4.1.1 . Whether this version supporting these endpoints? === Step 1: Upload dashboards === Starting Superset Asset Sync Process... --- Performing initial ZIP file checks --- All required ZIP files found. Archive: /tmp/repo/databases/databases.zip Length Date Time Name --------- ---------- ----- ---- 76 1979-12-31 18:30 metadata.yaml 0 2025-06-18 05:06 databases/ 394 1979-12-31 18:30 databases/VITE_Reporting.yaml --------- ------- 470 3 files Archive: /tmp/repo/datasets/datasets.zip Length Date Time Name --------- ---------- ----- ---- 77 1979-12-31 18:30 metadata.yaml 0 2025-06-18 04:59 datasets/ 0 2025-06-18 05:06 datasets/VITE_Reporting/ 3176 1979-12-31 18:30 datasets/VITE_Reporting/cs_acc_bu_cus_wrhouse.yaml 0 2025-06-18 05:06 databases/ 395 1979-12-31 18:30 databases/VITE_Reporting.yaml --------- ------- 3648 6 files Archive: /tmp/repo/charts/charts.zip Length Date Time Name --------- ---------- ----- ---- 73 1979-12-31 18:30 metadata.yaml 0 2025-06-18 05:05 charts/ 1700 1979-12-31 18:30 charts/RichardCICDtest_666.yaml 0 2025-06-18 04:58 datasets/ 0 2025-06-18 05:06 datasets/VITE_Reporting/ 3176 1979-12-31 18:30 datasets/VITE_Reporting/cs_acc_bu_cus_wrhouse.yaml 0 2025-06-18 05:06 databases/ 395 1979-12-31 18:30 databases/VITE_Reporting.yaml --------- ------- 5344 8 files Archive: /tmp/repo/dashboards/dashboards.zip Length Date Time Name --------- ---------- ----- ---- 77 1979-12-31 18:30 metadata.yaml 0 2025-06-18 05:06 charts/ 1664 1979-12-31 18:30 charts/RichardCICDtest_593.yaml 1700 1979-12-31 18:30 charts/RichardCICDtest_666.yaml 0 2025-06-18 04:58 datasets/ 0 2025-06-18 05:06 datasets/VITE_Reporting/ 3176 1979-12-31 18:30 datasets/VITE_Reporting/cs_acc_bu_cus_wrhouse.yaml 0 2025-06-18 05:06 databases/ 395 1979-12-31 18:30 databases/VITE_Reporting.yaml 0 2025-06-18 05:04 dashboards/ 4659 1979-12-31 18:30 dashboards/RichardCICDtest_171.yaml --------- ------- 11671 11 files --- Initial Authentication with Superset API --- DEBUG: Access Token retrieved. DEBUG: CSRF Token retrieved.
=== Importing database from /tmp/repo/databases/databases.zip === ERROR: Failed to import database from /tmp/repo/databases/databases.zip. HTTP response code: 422 Response body: {"errors": [{"message": "Could not find a valid command to import file", "error_type": "GENERIC_COMMAND_ERROR", "level": "warning", "extra": {"issue_codes": [{"code": 1010, "message": "Issue 1010 - Superset encountered an error while running a command."}]}}]}--- === Importing dataset from /tmp/repo/datasets/datasets.zip === ERROR: Failed to import dataset from /tmp/repo/datasets/datasets.zip. HTTP response code: 422 Response body: {"errors": [{"message": "Could not find a valid command to import file", "error_type": "GENERIC_COMMAND_ERROR", "level": "warning", "extra": {"issue_codes": [{"code": 1010, "message": "Issue 1010 - Superset encountered an error while running a command."}]}}]}--- === Importing chart from /tmp/repo/charts/charts.zip === ERROR: Failed to import chart from /tmp/repo/charts/charts.zip. HTTP response code: 422 Response body: {"errors": [{"message": "Could not find a valid command to import file", "error_type": "GENERIC_COMMAND_ERROR", "level": "warning", "extra": {"issue_codes": [{"code": 1010, "message": "Issue 1010 - Superset encountered an error while running a command."}]}}]}---
Comment From: dosubot[bot]
Superset 4.1.1 does support the import endpoints for databases, datasets, charts, and dashboards—there are no breaking changes in this area between 4.0.x and 4.1.x, so your endpoints and general approach are correct reference.
The error "Could not find a valid command to import file" almost always means the ZIP file's internal structure or the metadata.yaml is not exactly what Superset expects. The metadata.yaml must be at the root of the ZIP and must contain at least a version field with the value 1.0.0
reference. For example:
version: 1.0.0
type: assets
If the version is missing or incorrect, or if the file is not named exactly metadata.yaml
, you'll get this error. Also, make sure there are no extra files (like system files or hidden files) in the ZIP, and that all YAML files are in the correct subfolders (e.g., databases/
, datasets/
, etc.).
If you still get the error, try opening your ZIP and checking that:
- The root contains only metadata.yaml
and the asset folders.
- The metadata.yaml
is valid YAML and matches the expected version.
- All referenced dependencies are present in the bundle.
If you want Superset to use existing dependencies instead of requiring all dependencies in the ZIP, you can try adding the sparse=true
form field to your request (if your version supports it) reference.
If everything looks correct and you still get the error, there may be a subtle formatting or encoding issue with the ZIP or YAML files. Double-check for typos, encoding problems, or hidden files.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other