microsoft/semantic-kernel · error · VectorStoreOperationException

Failed to delete collection {self.collection_name} with erro

Error message

Failed to delete collection {self.collection_name} with error: {e}

What it means

A VectorStoreOperationException raised in ensure_collection_deleted() when client.delete_collection() raises something other than ValueError. The ValueError branch (collection does not exist) is swallowed with an info log; all other exceptions (auth errors, connection errors, server-side failures) are re-raised with the original error text appended via the {e} placeholder.

Source

Thrown at python/semantic_kernel/connectors/chroma.py:190

                    space=DISTANCE_FUNCTION_MAP[vector_field.distance_function]
                )
            else:
                configuration["hnsw"]["space"] = DISTANCE_FUNCTION_MAP[vector_field.distance_function]
            kwargs["configuration"] = configuration
        if "get_or_create" not in kwargs:
            kwargs["get_or_create"] = True

        self.client.create_collection(name=self.collection_name, embedding_function=self.embedding_func, **kwargs)

    @override
    async def ensure_collection_deleted(self, **kwargs: Any) -> None:
        """Delete the collection."""
        try:
            self.client.delete_collection(name=self.collection_name)
        except ValueError:
            logger.info(f"Collection {self.collection_name} could not be deleted because it doesn't exist.")
        except Exception as e:
            raise VectorStoreOperationException(
                f"Failed to delete collection {self.collection_name} with error: {e}"
            ) from e

    def _validate_data_model(self):
        super()._validate_data_model()
        if len(self.definition.vector_fields) > 1:
            raise VectorStoreModelValidationError(
                f"Chroma only supports one vector field, but {len(self.definition.vector_fields)} were provided."
            )

    @override
    def _serialize_dicts_to_store_models(self, records: Sequence[dict[str, Any]], **kwargs: Any) -> Sequence[Any]:
        vector_field = self.definition.vector_fields[0]
        id_field_name = self.definition.key_name
        store_models = []
        for record in records:
            store_model = {
                "id": record[id_field_name],

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Inspect the original exception text embedded in the message and __cause__ to classify the failure (connection / auth / server).
  2. For transient network/server errors, retry ensure_collection_deleted() with backoff.
  3. Ensure the Chroma client credentials, host, and database/tenant are correct before deletion.
Defensive patterns

Strategy: retry

Validate before calling

if not await collection.collection_exists():
    return  # nothing to delete

Try / catch

from semantic_kernel.exceptions.vector_store_exceptions import VectorStoreOperationException
try:
    await collection.ensure_collection_deleted()
except VectorStoreOperationException as e:
    if is_transient(e.__cause__):
        await backoff_retry(lambda: collection.ensure_collection_deleted())
    else:
        raise

Prevention

When it happens

Trigger: Calling await collection.ensure_collection_deleted() against a remote Chroma server that is unreachable, returns a permission error, or fails the delete for an internal reason; an expired API token or wrong tenant.

Common situations: Tearing down collections in CI against a shared/remote Chroma instance; deleting after the client's auth token expired; network blips during cleanup.

Related errors


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