microsoft/semantic-kernel · error · ServiceResponseException

Failed to create collection {collection_name}

Error message

Failed to create collection {collection_name}

What it means

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.

Source

Thrown at python/semantic_kernel/connectors/memory_stores/redis/redis_memory_store.py:151

            schema = (
                TextField(name="key"),
                TextField(name="metadata"),
                TextField(name="timestamp"),
                VectorField(
                    name="embedding",
                    algorithm=self._vector_index_algorithm,
                    attributes={
                        "TYPE": self._vector_type_str,
                        "DIM": self._vector_size,
                        "DISTANCE_METRIC": self._vector_distance_metric,
                    },
                ),
            )

            try:
                self._ft(collection_name).create_index(definition=index_def, fields=schema)
            except Exception as e:
                raise ServiceResponseException(f"Failed to create collection {collection_name}") from e

    async def get_collections(self) -> list[str]:
        """Returns a list of names of all collection names present in the data store.

        Returns:
            List[str]: list of collection names
        """
        # Note: FT._LIST is a temporary command that may be deprecated in the future according to Redis
        return [name.decode() for name in self._database.execute_command("FT._LIST")]

    async def delete_collection(self, collection_name: str, delete_records: bool = True) -> None:
        """Deletes a collection from the data store.

        If the collection does not exist, the database is left unchanged.

        Args:
            collection_name (str): Name for a collection of embeddings
            delete_records (bool): Delete all data associated with the collection, default to True

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Run a Redis image with RediSearch/RedisStack (e.g. redis/redis-stack-server).
  2. Inspect the chained exception (e) for the exact ResponseError text from Redis.
  3. Ensure vector_size and distance metric are valid for RediSearch (COSINE/L2/IP).
  4. If the index exists under a stale prefix, drop it via delete_collection() and recreate.

Example fix

// before
await store.create_collection('mycol')
// after
try:
    await store.create_collection('mycol')
except ServiceResponseException as e:
    print('redis said:', e.__cause__)
Defensive patterns

Strategy: try-catch

Try / catch

try:
    await store.create_collection(collection_name)
except ServiceResponseException as e:
    cause = e.__cause__
    # branch on Redis ResponseError text (e.g. module missing, bad attrs)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/94ff7501685f6940. Report an issue: GitHub.