{"record":{"id":"e19b4f8e8dfaee93","repo":"microsoft/semantic-kernel","slug":"collection-collection-name-does-not-exist-e19b4f","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/redis/redis_memory_store.py","lineNumber":207,"sourceCode":"    async def upsert(self, collection_name: str, record: MemoryRecord) -> str:\n        \"\"\"Upsert a memory record into the data store.\n\n        Does not guarantee that the collection exists.\n            * If the record already exists, it will be updated.\n            * If the record does not exist, it will be created.\n\n        Note: if the record do not have the same dimensionality configured for the collection,\n        it will not be detected to belong to the collection in Redis.\n\n        Args:\n            collection_name (str): Name for a collection of embeddings\n            record (MemoryRecord): Memory record to upsert\n\n        Returns:\n            str: Redis key associated with the upserted memory record\n        \"\"\"\n        if not await self.does_collection_exist(collection_name):\n            raise ServiceResourceNotFoundError(f'Collection \"{collection_name}\" does not exist')\n\n        # Typical Redis key structure: collection_name:{some identifier}\n        record._key = get_redis_key(collection_name, record._id)\n\n        # Overwrites previous data or inserts new key if not present\n        # Index registers any hash matching its schema and prefixed with collection_name:\n        try:\n            self._database.hset(\n                record._key,\n                mapping=serialize_record_to_redis(record, self._vector_type),\n            )\n            return record._key\n        except Exception as e:\n            raise ServiceResponseException(\"Could not upsert messages.\") from e\n\n    async def upsert_batch(self, collection_name: str, records: list[MemoryRecord]) -> list[str]:\n        \"\"\"Upserts a group of memory records into the data store.\n","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/redis/redis_memory_store.py#L189-L225","documentation":"Raised by RedisMemoryStore.upsert() when does_collection_exist(collection_name) returns False, i.e. FT.INFO on that index raises ResponseError. In Redis a 'collection' is the search index, so absence means create_collection() (create_index) never ran or was dropped. ServiceResourceNotFoundError with double-quoted collection name.","triggerScenarios":"Calling `await store.upsert(collection_name, record)` before create_collection(), or after the index was dropped/deleted. Because hashes are stored by key prefix, upsert refuses to write without a backing index to avoid orphaned, unindexed data.","commonSituations":"Skipping create_collection() on a fresh Redis; wrong collection name; index dropped by another process; RediSearch module restarted and lost in-memory index metadata.","solutions":["Call `await store.create_collection(collection_name)` before the first upsert.","Pre-check does_collection_exist() and create on demand.","Confirm the Redis instance has RediSearch and the index is listed in FT._LIST (get_collections()).","Migrate to the non-deprecated RedisStore/RedisHashsetCollection for managed lifecycle."],"exampleFix":"// before\nkey = await store.upsert('mycol', record)\n// after\nif not await store.does_collection_exist('mycol'):\n    await store.create_collection('mycol')\nkey = await store.upsert('mycol', record)","handlingStrategy":"validation","validationCode":"if not await store.does_collection_exist(collection_name):\n    await store.create_collection(collection_name)\nkey = await store.upsert(collection_name, record)","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions import ServiceResourceNotFoundError\ntry:\n    key = await store.upsert(collection_name, record)\nexcept ServiceResourceNotFoundError:\n    await store.create_collection(collection_name)\n    key = await store.upsert(collection_name, record)","preventionTips":["Run create_collection() at startup for every collection you write to.","Remember a Redis 'collection' is a RediSearch index, not a Redis database.","Confirm the index appears in get_collections() (FT._LIST)."],"tags":["redis","memory-store","collection-not-found","redisearch","service-resource-not-found"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}