microsoft/semantic-kernel · error · VectorStoreOperationException
Failed to list collection names.
Error message
Failed to list collection names.
What it means
Raised by the NoSQL store's list_collection_names when enumerating containers via database.list_containers() fails for any reason. The broad except Exception wraps the original error. This is a VectorStoreOperationException surfaced as a metadata/management failure rather than a data failure.
Source
Thrown at python/semantic_kernel/connectors/azure_cosmos_db.py:1137
embedding_generator=embedding_generator or self.embedding_generator,
url=str(self.cosmos_db_nosql_settings.url),
key=self.cosmos_db_nosql_settings.key.get_secret_value() if self.cosmos_db_nosql_settings.key else None,
cosmos_client=self.cosmos_client,
partition_key=None,
create_database=self.create_database,
env_file_path=None,
env_file_encoding=None,
**kwargs,
)
@override
async def list_collection_names(self, **kwargs) -> Sequence[str]:
try:
database = await self._get_database_proxy()
containers = database.list_containers()
return [container["id"] async for container in containers]
except Exception as e:
raise VectorStoreOperationException("Failed to list collection names.") from e
@override
async def __aexit__(self, exc_type, exc_value, traceback) -> None:
"""Exit the context manager."""
if self.managed_client:
await self.cosmos_client.close()
View on GitHub (pinned to c028a0c7dc)
Solutions
- Inspect exc.__cause__ for the underlying error and status code.
- Verify the database name and endpoint in the store settings and that the identity/key has database-read permission.
- Ensure the cosmos client is connected (or that managed_client is True) before listing collections.
Example fix
// before
names = await store.list_collection_names() # opaque 'Failed to list collection names.'
// after
try:
names = await store.list_collection_names()
except VectorStoreOperationException as e:
logger.error("list failed: %s", e.__cause__)
names = []
Defensive patterns
Strategy: try-catch
Try / catch
from semantic_kernel.exceptions import VectorStoreOperationException
try:
names = await store.list_collection_names()
except VectorStoreOperationException as e:
logger.error("list_collection_names failed: %s", e.__cause__)
names = [] Prevention
- Verify database name and endpoint in store settings before listing.
- Ensure read permission on the database and an initialized cosmos client.
- Fall back gracefully when listing is non-critical.
When it happens
Trigger: Calling list_collection_names while the database proxy cannot be reached, the database does not exist, credentials are invalid, the SDK client is not connected, or a service/network error occurs during the async iteration.
Common situations: Wrong database name in settings; missing 'read database' permission; the managed cosmos_client was never initialized; or transient connectivity issues to the Cosmos endpoint.
Related errors
- Container could not be deleted.
- Failed to search the collection.
- Failed to check if database '{self.database_name}' exists, w
- Failed to get database proxy for '{id}'.
- Failed to get container proxy for '{container_name}'.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/877e4422f44fa763.
Report an issue: GitHub.