apache/superset · error · CommandInvalidError
Could not find a valid command to import file
Error message
Could not find a valid command to import file
What it means
CommandInvalidError('Could not find a valid command to import file') is raised by the dashboard import dispatcher when no registered import command accepts the uploaded bundle. Each importer is tried in order; an IncorrectVersionError (bundle version not handled) makes the dispatcher skip to the next, and if all are exhausted this error is raised. It means the ZIP/YAML's metadata version does not match any supported import format.
Source
Thrown at superset/commands/dashboard/importers/dispatcher.py:70
# iterate over all commands until we find a version that can
# handle the contents
for version in command_versions:
command = version(self.contents, *self.args, **self.kwargs)
try:
command.run()
return
except IncorrectVersionError:
logger.debug("File not handled by command, skipping")
except (CommandInvalidError, ValidationError):
# found right version, but file is invalid
logger.info("Command failed validation")
raise
except Exception:
# validation succeeded but something went wrong
logger.exception("Error running import command")
raise
raise CommandInvalidError("Could not find a valid command to import file")
def validate(self) -> None:
pass
View on GitHub (pinned to f4587218dd)
Solutions
- Check the bundle's metadata.yaml: the 'version' field must match a version this Superset's dashboard importers support (e.g. '1.0'/'v1').
- Re-export the bundle from a Superset version at or older than the target instance, then import.
- Confirm you are uploading to the matching resource endpoint (dashboard bundle to /api/v1/dashboard/import/).
- Unzip and verify the structure matches an actual export (dashboard metadata + YAML files) before zipping it back.
Example fix
# before
# bundle exported from Superset 5.x with metadata version '2.0' uploaded to 4.x
client.post('/api/v1/dashboard/import/', files={'formData': open('dash.zip', 'rb')})
# after
# unzip, set metadata.yaml -> version: '1.0' (only if schema compatible), re-zip;
# otherwise re-export from a matching-version instance Defensive patterns
Strategy: validation
Validate before calling
import zipfile, yaml
with zipfile.ZipFile(path) as z:
meta = yaml.safe_load(z.read('metadata.yaml'))
supported = {'1.0', '1.1'} # versions this instance's importers accept
if str(meta.get('version')) not in supported:
raise ValueError(f'unsupported bundle version {meta.get("version")}') Try / catch
try:
importer.run()
except CommandInvalidError as ex:
if 'Could not find a valid command' in str(ex):
# version mismatch: re-export from a compatible instance
re_export_from_compatible_instance() Prevention
- Match export and import Superset versions for bundle portability.
- Validate metadata.yaml version before uploading.
- Upload bundles to the resource-specific import endpoint they were exported from.
When it happens
Trigger: Uploading an export bundle whose metadata.yaml version is newer than this Superset supports, or a hand-built ZIP missing/renaming metadata.yaml, or a non-dashboard bundle (e.g. database export) posted to the dashboard import endpoint.
Common situations: Importing a bundle exported from a newer Superset into an older instance; downloading a database-or-chart export and uploading it as a dashboard import; editing the YAML files inside the ZIP and corrupting the version field.
Related errors
- No data in file
- Could not find a valid command to import file
- No valid import files were found
- No dashboard found for uuid ${sourceUuid}
- A valid color scheme is required
AI-assisted analysis of apache/superset@f4587218dd (2026-08-14).
Data as JSON: /api/errors/c27120ebf049a5d5.
Report an issue: GitHub.