{"record":{"id":"5c136dd4776bd544","repo":"apache/superset","slug":"file-name-has-no-valid-keys","errorCode":null,"errorMessage":"{file_name} has no valid keys","messagePattern":"(.+?) has no valid keys","errorType":"validation","errorClass":"IncorrectVersionError","httpStatus":422,"severity":"error","filePath":"superset/commands/dataset/importers/v0.py","lineNumber":311,"sourceCode":"                    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\n","sourceCodeStart":293,"sourceCodeEnd":322,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/dataset/importers/v0.py#L293-L322","documentation":"Raised by the legacy (v0) dataset YAML import loader when the parsed YAML is a mapping (CLI-export format) but does not contain the required top-level 'databases' key. It is wrapped as IncorrectVersionError because the v0 importer expects exports produced by the old CLI export command, whose schema is keyed by DATABASES_KEY. A YAML file that parses fine but was exported in a different format therefore fails schema-shape validation.","triggerScenarios":"Calling the import API or CLI import command with a YAML file whose root is a dict lacking the 'databases' key — e.g. a v1-format export (root is a 'dataset' mapping), a hand-written YAML, or a truncated/corrupted export bundle.","commonSituations":"Mixing export formats: user downloads a YAML from a newer Superset (v1 format with 'dataset' root) and imports it through the legacy v0 path; or the upload bundle is missing the databases.yaml file and a dataset YAML is misinterpreted.","solutions":["Re-export the bundle with the matching export version (v1 export for v1 import) so the YAML schema matches the importer","Inspect the YAML root: the v0 CLI format requires a top-level 'databases' key; add it or use the file that has it","If importing via API, ensure the file goes under 'datasets/' in the bundle so the v1 importer (which expects a list) handles it instead of v0"],"exampleFix":"# before: YAML root lacks the key\nsome_column: ...\n# after (v0 CLI format)\ndatabases:\n  - database_name: examples\n    ...","handlingStrategy":"validation","validationCode":"import yaml\nDatabasesKey = 'databases'\nwith open(path) as f:\n    cfg = yaml.safe_load(f)\nif not isinstance(cfg, (dict, list)):\n    raise ValueError(f'{path}: root must be a mapping (v0 CLI export) or list (v0 UI export)')\nif isinstance(cfg, dict) and DatabasesKey not in cfg:\n    raise ValueError(f'{path}: v0 CLI export requires a top-level \"{DatabasesKey}\" key — use the v1 import path for v1 bundles')","typeGuard":"def is_v0_cli_export(cfg: object) -> bool:\n    return isinstance(cfg, dict) and 'databases' in cfg\n\ndef is_v0_ui_export(cfg: object) -> bool:\n    return isinstance(cfg, list)","tryCatchPattern":"from superset.commands.importers.exceptions import IncorrectVersionError\ntry:\n    import_command.run()\nexcept IncorrectVersionError as ex:\n    # report the offending file to the uploader; do not retry — the bundle format is wrong\n    logging.warning('Bad bundle: %s', ex)","preventionTips":["Always export and import with the same format version (v1 export → v1 import)","Automate a yaml.safe_load + shape check in CI for bundles committed to a repo","Never hand-author v0 bundles; generate them with the export CLI/API"],"tags":["dataset-import","yaml","validation","superset"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}