{"record":{"id":"ba040f93c254de6a","repo":"langchain-ai/deepagents","slug":"unsupported-media-file-type-path","errorCode":null,"errorMessage":"unsupported media file type: {path}","messagePattern":"unsupported media file type: (.+?)","errorType":"exception","errorClass":"ChannelMediaError","httpStatus":null,"severity":"error","filePath":"libs/talon/deepagents_talon/channels/base.py","lineNumber":486,"sourceCode":"        f\"{config.open_ack}={config.open_ack_value} to acknowledge this risk\"\n    )\n    raise ValueError(msg)\n\n\ndef _split_index(text: str, limit: int) -> int:\n    window = text[:limit]\n    for delimiter in (\"\\n\\n\", \"\\n\", \" \"):\n        index = window.rfind(delimiter)\n        if index > 0:\n            return index + len(delimiter)\n    return limit\n\n\ndef _media_type(path: Path) -> str:\n    mime, _ = mimetypes.guess_type(path)\n    if mime is None:\n        msg = f\"unsupported media file type: {path}\"\n        raise ChannelMediaError(msg)\n    if mime.startswith(\"image/\"):\n        return \"image\"\n    if mime.startswith(\"video/\"):\n        return \"video\"\n    msg = f\"unsupported media mime type: {mime}\"\n    raise ChannelMediaError(msg)\n\n\n_RETRYABLE_ERROR_FRAGMENTS = frozenset(\n    {\n        \"connectionerror\",\n        \"connectionreset\",\n        \"connectionrefused\",\n        \"connecttimeout\",\n        \"timeout\",\n        \"broken pipe\",\n        \"remotedisconnected\",\n        \"eoferror\",","sourceCodeStart":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/talon/deepagents_talon/channels/base.py#L468-L504","documentation":"`_media_type` uses Python's `mimetypes.guess_type` to classify a media attachment by file extension. If the OS mimetype database cannot map the filename to a MIME type (unknown or missing extension), the function raises `ChannelMediaError` because the channel cannot determine whether the file is an image or video.","triggerScenarios":"Calling `validate_media` on a file whose name has no recognizable extension (e.g. `attachment`, `blob`, or a dotfile like `.preview`), so `mimetypes.guess_type(path)` returns `(None, None)`.","commonSituations":"Telegram senders upload files without extensions; downloaded media saved under opaque temp names; exotic formats not in the system mime database; files renamed during forwarding losing their extension.","solutions":["Rename the file to include a standard extension matching its actual type (e.g. `.jpg`, `.png`, `.mp4`) before validating.","Only send media types the channel supports (images and videos); strip or skip unsupported attachments before calling `validate_media`.","If the type is known but the extension is missing, copy the file to a name with the correct extension in your ingestion pipeline."],"exampleFix":"# before\npath = Path('/tmp/telegram_media/photo_001')  # no extension -> ChannelMediaError\n# after\npath = Path('/tmp/telegram_media/photo_001.jpg')","handlingStrategy":"validation","validationCode":"import mimetypes\nfrom pathlib import Path\ndef has_supported_media_extension(path: Path) -> bool:\n    mime, _ = mimetypes.guess_type(path)\n    return mime is not None and mime.startswith((\"image/\", \"video/\"))","typeGuard":"def is_media_file(path: Path) -> bool:\n    mime, _ = mimetypes.guess_type(path)\n    return mime is not None and mime.startswith((\"image/\", \"video/\"))","tryCatchPattern":"try:\n    media_type = validate_media(path)\nexcept ChannelMediaError as exc:\n    logging.warning(\"skipping attachment %s: %s\", path, exc)","preventionTips":["Always preserve file extensions when saving inbound media","Normalize opaque filenames by appending the correct extension based on the source metadata","Pre-screen attachments for supported types before ingestion","Keep the system mime database available (don't strip /etc/mime.types in slim containers)"],"tags":["media","validation","channels"],"backgroundTag":"unsupported-media-type","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}