{"record":{"id":"e36f28c5195aa92e","repo":"apache/superset","slug":"not-a-valid-yaml-file","errorCode":null,"errorMessage":"Not a valid YAML file","messagePattern":"Not a valid YAML file","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"superset/commands/importers/v1/utils.py","lineNumber":64,"sourceCode":"    \"\"\"Remove the first directory of a path\"\"\"\n    full_path = PurePosixPath(file_path)\n    relative_path = PurePosixPath(*full_path.parts[1:])\n    return str(relative_path)\n\n\nclass MetadataSchema(Schema):\n    version = fields.String(required=True, validate=validate.Equal(IMPORT_VERSION))\n    type = fields.String(required=False)\n    timestamp = fields.DateTime()\n\n\ndef load_yaml(file_name: str, content: str) -> dict[str, Any]:\n    \"\"\"Try to load a YAML file\"\"\"\n    try:\n        return yaml.safe_load(content)\n    except yaml.YAMLError as ex:\n        logger.exception(\"Invalid YAML in %s\", file_name)\n        raise ValidationError({file_name: \"Not a valid YAML file\"}) from ex\n\n\ndef load_metadata(contents: dict[str, str]) -> dict[str, str]:\n    \"\"\"Apply validation and load a metadata file\"\"\"\n    if METADATA_FILE_NAME not in contents:\n        # if the contents have no METADATA_FILE_NAME this is probably\n        # a original export without versioning that should not be\n        # handled by this command\n        raise IncorrectVersionError(f\"Missing {METADATA_FILE_NAME}\")\n\n    metadata = load_yaml(METADATA_FILE_NAME, contents[METADATA_FILE_NAME])\n    try:\n        MetadataSchema().load(metadata)\n    except ValidationError as ex:\n        # if the version doesn't match raise an exception so that the\n        # dispatcher can try a different command version\n        if \"version\" in ex.messages:\n            raise IncorrectVersionError(ex.messages[\"version\"][0]) from ex","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/importers/v1/utils.py#L46-L82","documentation":"Error \"Not a valid YAML file\" thrown in apache/superset.","triggerScenarios":"An uploaded import file cannot be parsed as YAML.","commonSituations":"Importing assets from an uploaded file whose contents are not parseable YAML.","solutions":["Ensure the file is valid YAML with a .yaml/.yml extension.","Validate the YAML syntax with a linter before uploading."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}