{"record":{"id":"259d9521457be68e","repo":"microsoft/semantic-kernel","slug":"collection-collection-name-does-not-exist-259d95","errorCode":null,"errorMessage":"Collection {collection_name} does not exist","messagePattern":"Collection (.+?) does not exist","errorType":"exception","errorClass":"ServiceResourceNotFoundError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/usearch/usearch_memory_store.py","lineNumber":397,"sourceCode":"            keys=[key],\n            with_embeddings=with_embedding,\n            dtype=dtype,\n        )\n        if not result:\n            raise ServiceResourceNotFoundError(f\"Key '{key}' not found in collection '{collection_name}'\")\n        return result[0]\n\n    async def get_batch(\n        self,\n        collection_name: str,\n        keys: list[str],\n        with_embeddings: bool,\n        dtype: ScalarKind = ScalarKind.F32,\n    ) -> list[MemoryRecord]:\n        \"\"\"Retrieve a batch of MemoryRecords using their keys.\"\"\"\n        collection_name = collection_name.lower()\n        if collection_name not in self._collections:\n            raise ServiceResourceNotFoundError(f\"Collection {collection_name} does not exist\")\n\n        ucollection = self._collections[collection_name]\n        labels = [ucollection.embeddings_id_to_label[key] for key in keys if key in ucollection.embeddings_id_to_label]\n        if not labels:\n            return []\n        vectors = ucollection.embeddings_index.get(labels, dtype) if with_embeddings else None\n\n        return pyarrow_table_to_memoryrecords(ucollection.embeddings_data_table.take(pa.array(labels)), vectors)\n\n    async def remove(self, collection_name: str, key: str) -> None:\n        \"\"\"Remove a single MemoryRecord using its key.\"\"\"\n        collection_name = collection_name.lower()\n        await self.remove_batch(collection_name=collection_name, keys=[key])\n        return\n\n    async def remove_batch(self, collection_name: str, keys: list[str]) -> None:\n        \"\"\"Remove a batch of MemoryRecords using their keys.\"\"\"\n        collection_name = collection_name.lower()","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/usearch/usearch_memory_store.py#L379-L415","documentation":"Raised by USearchMemoryStore.get_batch (ServiceResourceNotFoundError) when the target collection is not in `self._collections`, before attempting to resolve keys to labels. Unlike get() (which raises per-key), this guards the whole collection; the message is the plain 'Collection X does not exist'.","triggerScenarios":"Calling `await store.get_batch('docs', ['k1','k2'], with_embeddings=True)` against a collection that was never created/loaded in this process.","commonSituations":"Collection name typo or case mismatch (lowercased internally); in-memory store after restart; collection not loaded because persist_directory is unset; reading before any create_collection.","solutions":["Create/load the collection first with create_collection (or set persist_directory at construction).","Guard with does_collection_exist / `'docs' in store._collections` before reading.","Match the collection name exactly (case-insensitive)."],"exampleFix":"// before\nrecs = await store.get_batch('docs', keys, with_embeddings=True)\n// after\nif not await store.does_collection_exist('docs'):\n    recs = []\nelse:\n    recs = await store.get_batch('docs', keys, with_embeddings=True)","handlingStrategy":"validation","validationCode":"name = collection_name.lower()\nif not await store.does_collection_exist(name):\n    return []\nreturn await store.get_batch(name, keys, with_embeddings=True)","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions import ServiceResourceNotFoundError\ntry:\n    return await store.get_batch(collection_name, keys, with_embeddings=True)\nexcept ServiceResourceNotFoundError:\n    return []","preventionTips":["Check collection existence before batch reads.","Keep names lowercased and consistent across create/read.","Load from persist_directory at startup so expected collections are present."],"tags":["usearch","memory-store","collection-not-found"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}