{"record":{"id":"b14d1978698f7be7","repo":"microsoft/autogen","slug":"error-mime-type-is-not-supported-only-memorymi","errorCode":null,"errorMessage":"Error: {mime_type} is not supported. Only MemoryMimeType.TEXT, MemoryMimeType.JSON, and MemoryMimeType.MARKDOWN are currently supported.","messagePattern":"Error: (.+?) is not supported\\. Only MemoryMimeType\\.TEXT, MemoryMimeType\\.JSON, and MemoryMimeType\\.MARKDOWN are currently supported\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/memory/redis/_redis_memory.py","lineNumber":338,"sourceCode":"                raise TypeError(\"'query' must be either a string or MemoryContent\")\n\n            results = self.message_history.get_relevant(  # type: ignore\n                prompt=prompt,  # type: ignore[reportArgumentType]\n                top_k=top_k,\n                distance_threshold=distance_threshold,\n                raw=False,\n            )\n\n        memories: List[MemoryContent] = []\n        for result in results:  # type: ignore[reportUnkownVariableType]\n            metadata = deserialize(result[\"metadata\"])  # type: ignore[reportArgumentType]\n            mime_type = MemoryMimeType(metadata.pop(\"mime_type\"))\n            if mime_type in (MemoryMimeType.TEXT, MemoryMimeType.MARKDOWN):\n                memory_content = result[\"content\"]  # type: ignore[reportArgumentType]\n            elif mime_type == MemoryMimeType.JSON:\n                memory_content = deserialize(result[\"content\"])  # type: ignore[reportArgumentType]\n            else:\n                raise NotImplementedError(\n                    f\"Error: {mime_type} is not supported. Only MemoryMimeType.TEXT, MemoryMimeType.JSON, and MemoryMimeType.MARKDOWN are currently supported.\"\n                )\n            memory = MemoryContent(\n                content=memory_content,  # type: ignore[reportArgumentType]\n                mime_type=mime_type,\n                metadata=metadata,\n            )\n            memories.append(memory)  # type: ignore[reportUknownMemberType]\n\n        return MemoryQueryResult(results=memories)  # type: ignore[reportUknownMemberType]\n\n    async def clear(self) -> None:\n        \"\"\"Clear all entries from memory, preserving the RedisMemory resources.\"\"\"\n        self.message_history.clear()\n\n    async def close(self) -> None:\n        \"\"\"Clears all entries from memory, and cleans up Redis client, index and resources.\"\"\"\n        self.message_history.delete()","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/memory/redis/_redis_memory.py#L320-L356","documentation":"When RedisMemory deserializes stored rows back into MemoryContent, it pops 'mime_type' from the stored metadata and maps the string through MemoryMimeType(...). If the stored MIME string is not one of text/plain, text/markdown, application/json (the only ones add() ever writes), reconstruction raises NotImplementedError. This indicates corrupt or foreign data in the Redis index.","triggerScenarios":"Rows written to the same RedisVL index by another application with different mime_type metadata values (e.g. 'image/png', 'text/html'); manually edited/imported Redis entries; a MemoryContent stored by a newer/older version with a wider mime mapping.","commonSituations":"Sharing a Redis index between services; running migration scripts that inserted records directly; schema drift between environments writing to the same Redis instance.","solutions":["Use a dedicated index_name per application/version in RedisMemoryConfig so foreign rows never mix in.","Delete or re-write the offending rows: scan the index, fix or drop entries whose metadata.mime_type is outside the supported set, or clear() the memory.","If you control the writers, standardize on the three supported mime strings before inserting into Redis."],"exampleFix":"# before (foreign row in index: metadata {\"mime_type\": \"text/html\"})\nresults = await memory.query('anything')  # NotImplementedError on deserialize\n\n# after\nawait memory.clear()  # or delete offending keys, then re-add supported content\nresults = await memory.query('anything')","handlingStrategy":"try-catch","validationCode":"SUPPORTED_MIMES = {'text/plain', 'text/markdown', 'application/json'}\n\nasync def scan_for_bad_rows(memory) -> int:\n    # use RedisVL index scan on metadata.mime_type outside the supported set\n    ...","typeGuard":null,"tryCatchPattern":"try:\n    results = await memory.query(q)\nexcept NotImplementedError as e:\n    if 'not supported' in str(e):\n        logger.error('foreign rows in index; clearing and rebuilding memory')\n        await memory.clear()\n        results = await memory.query(q)\n    else:\n        raise","preventionTips":["Give each app/version its own RedisMemoryConfig index_name","Never write rows to the RedisVL index outside RedisMemory.add","Add a migration check on metadata.mime_type after upgrades"],"tags":["redis","data-corruption","deserialization","memory"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}