{"record":{"id":"3c04a21c7e862781","repo":"microsoft/markitdown","slug":"unknown-file-type-file-type","errorCode":null,"errorMessage":"Unknown file type: {file_type}","messagePattern":"Unknown file type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/markitdown/src/markitdown/converters/_cu_converter.py","lineNumber":261,"sourceCode":"    \"video\": \"prebuilt-videoSearch\",\n    \"audio\": \"prebuilt-audioSearch\",\n}\n\n# All supported file types (default set when file_types is None)\n_ALL_FILE_TYPES = list(ContentUnderstandingFileType)\n\n\ndef _get_modality(file_type: ContentUnderstandingFileType) -> str:\n    \"\"\"Get the modality category for a file type.\"\"\"\n    if file_type in _DOCUMENT_TYPES:\n        return \"document\"\n    elif file_type in _IMAGE_TYPES:\n        return \"image\"\n    elif file_type in _VIDEO_TYPES:\n        return \"video\"\n    elif file_type in _AUDIO_TYPES:\n        return \"audio\"\n    raise ValueError(f\"Unknown file type: {file_type}\")\n\n\ndef _detect_file_type(\n    stream_info: StreamInfo,\n    file_types: Optional[List[ContentUnderstandingFileType]] = None,\n) -> Optional[ContentUnderstandingFileType]:\n    \"\"\"Detect a supported CU file type from extension or MIME type.\"\"\"\n    allowed = set(file_types) if file_types is not None else None\n\n    extension = (stream_info.extension or \"\").lower()\n    file_type = _EXTENSION_MAP.get(extension)\n    if file_type is not None and (allowed is None or file_type in allowed):\n        return file_type\n\n    mimetype = _clean_mime_type(stream_info.mimetype)\n    if not mimetype:\n        return None\n","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/microsoft/markitdown/blob/fd239d5d2be43d9b68329730206b9312c7d5a388/packages/markitdown/src/markitdown/converters/_cu_converter.py#L243-L279","documentation":"_get_modality() maps a ContentUnderstandingFileType to document/image/video/audio by set membership and raises ValueError for a value outside all four sets. It is a defensive internal invariant: file types reaching it come from _EXTENSION_MAP, which is built from those sets, so via the public API this fires only if the internal tables drift out of sync (e.g. a custom build adds a type to the map without a modality set).","triggerScenarios":"Maintainers adding a new entry to _EXTENSION_MAP/_ALL_FILE_TYPES without registering it in _DOCUMENT_TYPES/_IMAGE_TYPES/_VIDEO_TYPES/_AUDIO_TYPES; or monkey-patched file_types lists injecting an unknown enum value.","commonSituations":"Forking/extending the CU converter with custom file types, or version skew after a partial upgrade where the enum and the converter tables come from different builds.","solutions":["Ensure any custom file type is added to exactly one of the four modality sets alongside _EXTENSION_MAP","Reinstall matching versions: pip install --force-reinstall markitdown to eliminate mixed-build skew","If you extended file_types, verify every enum member you pass exists in the supported modality sets"],"exampleFix":"# before (custom build)\n_EXTENSION_MAP['.xyz'] = ContentUnderstandingFileType.MY_TYPE  # later: ValueError in _get_modality\n\n# after\n_EXTENSION_MAP['.xyz'] = ContentUnderstandingFileType.MY_TYPE\n_DOCUMENT_TYPES.add(ContentUnderstandingFileType.MY_TYPE)","handlingStrategy":"validation","validationCode":"from markitdown.converters._cu_converter import (_DOCUMENT_TYPES, _IMAGE_TYPES, _VIDEO_TYPES, _AUDIO_TYPES)\n\nALL_KNOWN = _DOCUMENT_TYPES | _IMAGE_TYPES | _VIDEO_TYPES | _AUDIO_TYPES\n\ndef modality_known(file_type) -> bool:\n    return file_type in ALL_KNOWN","typeGuard":null,"tryCatchPattern":"try:\n    modality = _get_modality(file_type)\nexcept ValueError:\n    log.error(\"file type %s registered without a modality set\", file_type)\n    raise","preventionTips":["When forking/extending the CU converter, add new types to both _EXTENSION_MAP and exactly one modality set","Pin exact markitdown versions to avoid mixed-table builds after partial upgrades"],"tags":["azure","content-understanding","internal-invariant"],"backgroundTag":null,"analyzedSha":"fd239d5d2be43d9b68329730206b9312c7d5a388","analyzedAt":"2026-08-14T15:47:51.745Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}