{"record":{"id":"81e49a6406f771f6","repo":"microsoft/semantic-kernel","slug":"collection-collection-name-does-not-exist-canno","errorCode":null,"errorMessage":"Collection {collection_name} does not exist, cannot insert.","messagePattern":"Collection (.+?) does not exist, cannot insert\\.","errorType":"exception","errorClass":"ServiceResourceNotFoundError","httpStatus":404,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/milvus/milvus_memory_store.py","lineNumber":290,"sourceCode":"        \"\"\"_summary_.\n\n        Args:\n            collection_name (str): The collection name.\n            records (List[MemoryRecord]): A list of memory records.\n            batch_size (int, optional): Batch size of the insert, 0 is a batch\n                size of total size. Defaults to 100.\n\n        Raises:\n            Exception: Collection doesnt exist.\n            e: Failed to upsert a record.\n\n        Returns:\n            List[str]: A list of inserted ID's.\n        \"\"\"\n        # Check if the collection exists.\n        if collection_name not in utility.list_collections():\n            logger.debug(f\"Collection {collection_name} does not exist, cannot insert.\")\n            raise ServiceResourceNotFoundError(f\"Collection {collection_name} does not exist, cannot insert.\")\n        # Convert the records to dicts\n        insert_list = [memoryrecord_to_milvus_dict(record) for record in records]\n        try:\n            ids = self.collections[collection_name].upsert(data=insert_list).primary_keys\n            self.collections[collection_name].flush()\n            return ids\n        except Exception as e:\n            logger.debug(f\"Upsert failed due to: {e}\")\n            raise ServiceResponseException(f\"Upsert failed due to: {e}\") from e\n\n    async def get(self, collection_name: str, key: str, with_embedding: bool) -> MemoryRecord:\n        \"\"\"Get the MemoryRecord corresponding to the key.\n\n        Args:\n            collection_name (str): The collection to get from.\n            key (str): The ID to grab.\n            with_embedding (bool): Whether to include the embedding in the results.\n","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/milvus/milvus_memory_store.py#L272-L308","documentation":"Raised as a ServiceResourceNotFoundError in MilvusMemoryStore.upsert_batch when the collection name is not found in utility.list_collections(). Milvus requires a collection (with schema and index) to exist before data can be upserted; the store does not auto-create it.","triggerScenarios":"Calling await store.upsert_batch('my_collection', records) before create_collection. Also when the Milvus instance was reset/redeployed, dropping all collections, but the application still references old names.","commonSituations":"Forgetting to call create_collection during setup. Collection name typo. Milvus server restart with ephemeral storage. Connecting to a different Milvus instance/namespace than expected.","solutions":["Call await store.create_collection(...) for the collection before upserting.","Verify collection_name against utility.list_collections() output.","Catch ServiceResourceNotFoundError, create the collection, and retry the upsert.","Confirm you are connected to the correct Milvus host/port and database."],"exampleFix":"// before\nids = await store.upsert_batch('docs', records)  # ServiceResourceNotFoundError\n// after\ntry:\n    ids = await store.upsert_batch('docs', records)\nexcept ServiceResourceNotFoundError:\n    await store.create_collection('docs', ...)\n    ids = await store.upsert_batch('docs', records)","handlingStrategy":"validation","validationCode":"from pymilvus import utility\n\ndef collection_exists(name: str) -> bool:\n    return name in utility.list_collections()\n\nif not collection_exists('docs'):\n    await store.create_collection('docs', ...)\nids = await store.upsert_batch('docs', records)","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions import ServiceResourceNotFoundError\n\ntry:\n    ids = await store.upsert_batch('docs', records)\nexcept ServiceResourceNotFoundError:\n    await store.create_collection('docs', ...)\n    ids = await store.upsert_batch('docs', records)","preventionTips":["Run create_collection during setup before any upsert.","Verify the Milvus host/port/database point to the right instance.","Use utility.list_collections() to confirm names in integration tests.","Wrap upsert_batch in create-on-miss retry logic."],"tags":["milvus","collection","resource-not-found","upsert","python"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}