{"record":{"id":"94ff7501685f6940","repo":"microsoft/semantic-kernel","slug":"failed-to-create-collection-collection-name","errorCode":null,"errorMessage":"Failed to create collection {collection_name}","messagePattern":"Failed to create collection (.+?)","errorType":"exception","errorClass":"ServiceResponseException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/redis/redis_memory_store.py","lineNumber":151,"sourceCode":"            schema = (\n                TextField(name=\"key\"),\n                TextField(name=\"metadata\"),\n                TextField(name=\"timestamp\"),\n                VectorField(\n                    name=\"embedding\",\n                    algorithm=self._vector_index_algorithm,\n                    attributes={\n                        \"TYPE\": self._vector_type_str,\n                        \"DIM\": self._vector_size,\n                        \"DISTANCE_METRIC\": self._vector_distance_metric,\n                    },\n                ),\n            )\n\n            try:\n                self._ft(collection_name).create_index(definition=index_def, fields=schema)\n            except Exception as e:\n                raise ServiceResponseException(f\"Failed to create collection {collection_name}\") from e\n\n    async def get_collections(self) -> list[str]:\n        \"\"\"Returns a list of names of all collection names present in the data store.\n\n        Returns:\n            List[str]: list of collection names\n        \"\"\"\n        # Note: FT._LIST is a temporary command that may be deprecated in the future according to Redis\n        return [name.decode() for name in self._database.execute_command(\"FT._LIST\")]\n\n    async def delete_collection(self, collection_name: str, delete_records: bool = True) -> None:\n        \"\"\"Deletes a collection from the data store.\n\n        If the collection does not exist, the database is left unchanged.\n\n        Args:\n            collection_name (str): Name for a collection of embeddings\n            delete_records (bool): Delete all data associated with the collection, default to True","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/redis/redis_memory_store.py#L133-L169","documentation":"Raised by RedisMemoryStore.create_collection() when self._ft(collection_name).create_index(...) throws any Exception. It is wrapped as ServiceResponseException with the collection name interpolated and the original error chained. A 'collection' in Redis is a RediSearch index; create_index builds it from TextField/VectorField schema. The method first short-circuits if the index already exists (logs info), so this fires only on actual creation failure.","triggerScenarios":"Calling `await store.create_collection(collection_name)` when create_index raises: most commonly the RediSearch module is absent (ResponseError 'unknown command FT.CREATE'), the index name is invalid, or vector schema attributes (TYPE/DIM/DISTANCE_METRIC) are rejected.","commonSituations":"Plain Redis (no RedisStack/RediSearch) so FT commands are unavailable; dimension/distance-metric mismatch with stored data; index name collision on a different prefix; unsupported vector_type or index algorithm.","solutions":["Run a Redis image with RediSearch/RedisStack (e.g. redis/redis-stack-server).","Inspect the chained exception (e) for the exact ResponseError text from Redis.","Ensure vector_size and distance metric are valid for RediSearch (COSINE/L2/IP).","If the index exists under a stale prefix, drop it via delete_collection() and recreate."],"exampleFix":"// before\nawait store.create_collection('mycol')\n// after\ntry:\n    await store.create_collection('mycol')\nexcept ServiceResponseException as e:\n    print('redis said:', e.__cause__)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    await store.create_collection(collection_name)\nexcept ServiceResponseException as e:\n    cause = e.__cause__\n    # branch on Redis ResponseError text (e.g. module missing, bad attrs)","preventionTips":["Run redis-stack-server (RediSearch present) for any vector workload.","Inspect the chained cause for the exact Redis error before guessing.","Validate vector_size, distance metric, and type against RediSearch-supported values.","Drop stale indexes via delete_collection() before recreating."],"tags":["redis","memory-store","create-collection","redisearch","service-response-exception","configuration"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}