{"record":{"id":"93c650497e3a08d2","repo":"apache/superset","slug":"file-name-is-not-a-valid-yaml-file","errorCode":null,"errorMessage":"{file_name} is not a valid YAML file","messagePattern":"(.+?) is not a valid YAML file","errorType":"validation","errorClass":"IncorrectVersionError","httpStatus":422,"severity":"error","filePath":"superset/commands/dataset/importers/v0.py","lineNumber":303,"sourceCode":"                    # UI exports don't have the database metadata, so we assume\n                    # the DB exists and has the same name\n                    params = json.loads(dataset[\"params\"])\n                    database = (\n                        db.session.query(Database)\n                        .filter_by(database_name=params[\"database_name\"])\n                        .one()\n                    )\n                    dataset[\"database_id\"] = database.id\n                    SqlaTable.import_from_dict(dataset, sync=self.sync)\n\n    def validate(self) -> None:\n        # ensure all files are YAML\n        for file_name, content in self.contents.items():\n            try:\n                config = yaml.safe_load(content)\n            except yaml.YAMLError as ex:\n                logger.exception(\"Invalid YAML file\")\n                raise IncorrectVersionError(\n                    f\"{file_name} is not a valid YAML file\"\n                ) from ex\n\n            # CLI export\n            if isinstance(config, dict):\n                # TODO (betodealmeida): validate with Marshmallow\n                if DATABASES_KEY not in config:\n                    raise IncorrectVersionError(f\"{file_name} has no valid keys\")\n\n            # UI export\n            elif isinstance(config, list):\n                # TODO (betodealmeida): validate with Marshmallow\n                pass\n\n            else:\n                raise IncorrectVersionError(f\"{file_name} is not a valid file\")\n\n            self._configs[file_name] = config","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/dataset/importers/v0.py#L285-L321","documentation":"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.","triggerScenarios":"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.","commonSituations":"Hand-editing exported YAML and breaking indentation; files edited with editors inserting tabs; partial uploads; converting exports through scripts that mangle quoting.","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."],"exampleFix":"# before (tab indentation -> yaml.YAMLError)\n- table_name: sales\n\tcolumns:\n\t\t- column_name: id\n\n# after (spaces only)\n- table_name: sales\n  columns:\n    - column_name: id","handlingStrategy":"validation","validationCode":"# Lint every file for YAML validity before upload\nimport yaml\n\ndef invalid_yaml_files(contents: dict) -> list[str]:\n    bad = []\n    for name, text in contents.items():\n        try:\n            yaml.safe_load(text)\n        except yaml.YAMLError:\n            bad.append(name)\n    return bad  # non-empty -> fix these files before calling the importer","typeGuard":null,"tryCatchPattern":"from superset.commands.exceptions import IncorrectVersionError\nbad = invalid_yaml_files(contents)\nif bad:\n    reject_upload(bad)  # client-side: name the files, never call the API\nelse:\n    ImportDatasetsCommand(contents, {})","preventionTips":["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."],"tags":["import-export","yaml","validation","legacy-v0"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}