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' raised by the theme import dispatcher after iterating every registered import command: none accepted the uploaded bundle. Each command attempts load_and_validate; version mismatches are skipped silently (IncorrectVersionError logged as debug), while files that match a version but fail validation raise immediately. Reaching the final raise means no command's version check matched the bundle's metadata.
Source
Thrown at superset/commands/theme/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
- Verify the export came from the same or older Superset version than the target; re-export from a matching version.
- Check the bundle's metadata version key against the versions the dispatcher registers (see the command registry in importers/dispatcher.py).
- Confirm you are using the correct import endpoint/command for the file type.
- Re-download or re-zip the export without altering internal file names.
Defensive patterns
Strategy: try-catch
Validate before calling
import zipfile, json
with zipfile.ZipFile(path) as z:
meta = json.loads(z.read([n for n in z.namelist() if n.endswith("metadata.yaml") or n.endswith("meta.yaml")][0]))
assert meta.get("version") in SUPPORTED_BUNDLE_VERSIONS, meta.get("version") Try / catch
try:
ImportThemesCommand(path, overwrite).run()
except CommandInvalidError as ex:
if "Could not find a valid command" in str(ex.message):
show_error("unsupported bundle version — re-export from a compatible Superset") Prevention
- Import bundles between same-or-older -> newer Superset versions only.
- Never re-zip exports by hand; altered metadata breaks version detection.
- Upload each file through the importer meant for its type.
When it happens
Trigger: Uploading an import file whose bundle version/structure matches no registered importer — e.g. a theme export with a missing or future VERSION in its metadata, a dashboard bundle passed to the theme import endpoint, or a hand-edited ZIP with damaged metadata.
Common situations: Export from a newer Superset imported into an older instance (version key not recognized); wrong file uploaded to the wrong importer; ZIP repackaging that drops or renames the metadata file; file type supported by a different command family.
Related errors
- Not a ZIP file
- No valid import files were found
- Could not find a valid command to import file
- Could not find a valid command to import file
- {file_name} is not a valid YAML file
AI-assisted analysis of apache/superset@f4587218dd (2026-08-14).
Data as JSON: /api/errors/2ed34270e116774e.
Report an issue: GitHub.