apache/superset · error · IncorrectVersionError
{file_name} is not a valid YAML file
Error message
{file_name} is not a valid YAML file What it means
IncorrectVersionError ('{file_name} is not a valid YAML file') is raised by the v0 importer's validate() when yaml.safe_load(content) raises a yaml.YAMLError — the file's content is syntactically invalid YAML (bad indentation, stray tabs, unclosed quotes/brackets). It is raised as IncorrectVersionError so the dispatcher treats it as 'file not handled' and moves on, ultimately surfacing as the 'Could not find a valid command to import file' error if no importer accepts any file.
Source
Thrown at superset/commands/dataset/importers/v0.py:303
# UI exports don't have the database metadata, so we assume
# the DB exists and has the same name
params = json.loads(dataset["params"])
database = (
db.session.query(Database)
.filter_by(database_name=params["database_name"])
.one()
)
dataset["database_id"] = database.id
SqlaTable.import_from_dict(dataset, sync=self.sync)
def validate(self) -> None:
# ensure all files are YAML
for file_name, content in self.contents.items():
try:
config = yaml.safe_load(content)
except yaml.YAMLError as ex:
logger.exception("Invalid YAML file")
raise IncorrectVersionError(
f"{file_name} is not a valid YAML file"
) from ex
# CLI export
if isinstance(config, dict):
# TODO (betodealmeida): validate with Marshmallow
if DATABASES_KEY not in config:
raise IncorrectVersionError(f"{file_name} has no valid keys")
# UI export
elif isinstance(config, list):
# TODO (betodealmeida): validate with Marshmallow
pass
else:
raise IncorrectVersionError(f"{file_name} is not a valid file")
self._configs[file_name] = configView on GitHub (pinned to f4587218dd)
Solutions
- Open the named file and run it through a YAML linter or `python -c "import yaml,sys; yaml.safe_load(open(sys.argv[1]))" file.yaml` to get the exact line/column of the syntax error.
- Replace tabs with spaces and fix indentation/quote issues at the reported position.
- Prefer regenerating the export from the source instance rather than hand-repairing.
Example fix
# before (tab indentation -> yaml.YAMLError)
- table_name: sales
columns:
- column_name: id
# after (spaces only)
- table_name: sales
columns:
- column_name: id Defensive patterns
Strategy: validation
Validate before calling
# Lint every file for YAML validity before upload
import yaml
def invalid_yaml_files(contents: dict) -> list[str]:
bad = []
for name, text in contents.items():
try:
yaml.safe_load(text)
except yaml.YAMLError:
bad.append(name)
return bad # non-empty -> fix these files before calling the importer Try / catch
from superset.commands.exceptions import IncorrectVersionError
bad = invalid_yaml_files(contents)
if bad:
reject_upload(bad) # client-side: name the files, never call the API
else:
ImportDatasetsCommand(contents, {}) Prevention
- Validate YAML in the upload pipeline (yaml.safe_load) and surface file+line before hitting the server.
- Configure editors to use spaces (never tabs) for YAML.
- Transport bundles as generated (ZIP), avoiding copy-paste through chat tools that truncate or reformat.
When it happens
Trigger: Importing a bundle containing a malformed YAML file: tabs used for indentation, a value with an unescaped colon, truncated download/copy-paste, or a binary/JSON file misnamed .yaml. The error message names the offending file_name.
Common situations: Hand-editing exported YAML and breaking indentation; files edited with editors inserting tabs; partial uploads; converting exports through scripts that mangle quoting.
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
- User doesn't have permission to create or update databases
AI-assisted analysis of apache/superset@f4587218dd (2026-08-14).
Data as JSON: /api/errors/93c650497e3a08d2.
Report an issue: GitHub.