{"record":{"id":"ee5529a61be40277","repo":"apache/superset","slug":"file-name-is-not-a-valid-file","errorCode":null,"errorMessage":"{file_name} is not a valid file","messagePattern":"(.+?) is not a valid file","errorType":"validation","errorClass":"IncorrectVersionError","httpStatus":422,"severity":"error","filePath":"superset/commands/dataset/importers/v0.py","lineNumber":319,"sourceCode":"            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":301,"sourceCodeEnd":322,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/dataset/importers/v0.py#L301-L322","documentation":"Raised by the legacy v0 dataset YAML import loader when yaml.safe_load produces neither a dict nor a list — i.e. the YAML root is a scalar, None (empty file), or some other non-container value. Both recognized export shapes (CLI dict, UI list) are containers, so anything else is treated as 'not a valid file'.","triggerScenarios":"Importing a YAML file that is empty (safe_load returns None), contains only a scalar/string/number, or has a document structure whose root is not a mapping or sequence.","commonSituations":"Empty upload file, a 0-byte file from a failed download, a plain-text file renamed to .yaml, or a YAML containing only comments.","solutions":["Check the file is non-empty and actually YAML (yaml.safe_load it locally and confirm the result is a dict or list)","Re-download or regenerate the export bundle","If the file only holds comments or stray text, remove it from the bundle"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import yaml\nfrom pathlib import Path\n\nfor f in Path(bundle_dir).glob('**/*.yaml'):\n    text = f.read_text()\n    if not text.strip():\n        raise ValueError(f'{f}: empty YAML file')\n    cfg = yaml.safe_load(text)\n    if not isinstance(cfg, (dict, list)):\n        raise ValueError(f'{f}: YAML root must be a mapping or list, got {type(cfg).__name__}')","typeGuard":"def has_valid_yaml_root(cfg: object) -> bool:\n    \"\"\"v0 loader accepts only dict (CLI) or list (UI) roots.\"\"\"\n    return isinstance(cfg, (dict, list))","tryCatchPattern":"from superset.commands.importers.exceptions import IncorrectVersionError\ntry:\n    importer.run()\nexcept IncorrectVersionError as ex:\n    if 'not a valid file' in str(ex):\n        # drop/fix the malformed file in the bundle, then re-run once\n        ...","preventionTips":["Reject zero-byte and comment-only files in upload validation before hitting the API","Validate uploaded bundles with a linter step (yaml.safe_load + root-type check)","Generate bundles only via the export API/CLI"],"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"}