{"record":{"id":"6b2551dde098b832","repo":"microsoft/autogen","slug":"unsupported-content-type-mime-type-6b2551","errorCode":null,"errorMessage":"Unsupported content type: {mime_type}","messagePattern":"Unsupported content type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/memory/chromadb/_chromadb.py","lineNumber":302,"sourceCode":"    def _extract_text(self, content_item: str | MemoryContent) -> str:\n        \"\"\"Extract searchable text from content.\"\"\"\n        if isinstance(content_item, str):\n            return content_item\n\n        content = content_item.content\n        mime_type = content_item.mime_type\n\n        if mime_type in [MemoryMimeType.TEXT, MemoryMimeType.MARKDOWN]:\n            return str(content)\n        elif mime_type == MemoryMimeType.JSON:\n            if isinstance(content, dict):\n                # Store original JSON string representation\n                return str(content).lower()\n            raise ValueError(\"JSON content must be a dict\")\n        elif isinstance(content, Image):\n            raise ValueError(\"Image content cannot be converted to text\")\n        else:\n            raise ValueError(f\"Unsupported content type: {mime_type}\")\n\n    def _calculate_score(self, distance: float) -> float:\n        \"\"\"Convert ChromaDB distance to a similarity score.\"\"\"\n        if self._config.distance_metric == \"cosine\":\n            return 1.0 - (distance / 2.0)\n        return 1.0 / (1.0 + distance)\n\n    async def update_context(\n        self,\n        model_context: ChatCompletionContext,\n    ) -> UpdateContextResult:\n        messages = await model_context.get_messages()\n        if not messages:\n            return UpdateContextResult(memories=MemoryQueryResult(results=[]))\n\n        # Extract query from last message\n        last_message = messages[-1]\n        query_text = last_message.content if isinstance(last_message.content, str) else str(last_message)","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/memory/chromadb/_chromadb.py#L284-L320","documentation":"_extract_text in ChromaDBVectorMemory only handles TEXT, MARKDOWN, and JSON (dict payload) contents. Any other MemoryMimeType value (e.g. IMAGE, BINARY, or a future enum member) falls into the else branch and raises ValueError with the offending mime type. This guards the string-only contract ChromaDB's document store requires.","triggerScenarios":"add() or query() with a MemoryContent whose mime_type is MemoryMimeType.IMAGE or MemoryMimeType.BINARY; a JSON content whose payload is a non-dict (e.g. list or string) also raises the sibling 'JSON content must be a dict' error; passing a custom/extended enum value.","commonSituations":"Sharing one MemoryContent pipeline across several memory backends with different supported-type matrices; upgrading autogen-ext and encountering a new MemoryMimeType member; storing JSON as a pre-serialized string instead of a dict.","solutions":["Convert the content to a supported form before add(): text/markdown string, or a dict for JSON mime type.","If content is JSON, pass a dict (not json.dumps output); the backend serializes it itself.","Switch to a memory backend that supports the mime type you need (e.g. RedisMemory for TEXT/JSON/MARKDOWN, or a custom Memory implementation for binary)."],"exampleFix":"// before\nawait memory.add(MemoryContent(content=b'raw-bytes', mime_type=MemoryMimeType.BINARY))\n\n// after\nawait memory.add(MemoryContent(content=b64encode(b'raw-bytes').decode(), mime_type=MemoryMimeType.TEXT, metadata={'encoding': 'base64'}))","handlingStrategy":"validation","validationCode":"from autogen_core.memory import MemoryContent, MemoryMimeType\n\nSUPPORTED = {MemoryMimeType.TEXT, MemoryMimeType.MARKDOWN, MemoryMimeType.JSON}\n\ndef validate_for_chroma(item: MemoryContent) -> bool:\n    if item.mime_type not in SUPPORTED:\n        return False\n    if item.mime_type == MemoryMimeType.JSON and not isinstance(item.content, dict):\n        return False\n    return True","typeGuard":"def is_chroma_supported(item: MemoryContent) -> bool:\n    return item.mime_type in {MemoryMimeType.TEXT, MemoryMimeType.MARKDOWN, MemoryMimeType.JSON} and not isinstance(item.content, Image)","tryCatchPattern":"try:\n    await memory.add(item)\nexcept ValueError as e:\n    if 'Unsupported content type' in str(e):\n        raise SkipMemoryItem(item.mime_type) from e\n    raise","preventionTips":["Centralize a supported-mime-type check per backend in your memory layer","Pass dicts (not strings) for JSON content","Log skipped mime types during ingestion to catch pipeline drift"],"tags":["chromadb","memory","mime-type","validation"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}