{"record":{"id":"877e4422f44fa763","repo":"microsoft/semantic-kernel","slug":"failed-to-list-collection-names","errorCode":null,"errorMessage":"Failed to list collection names.","messagePattern":"Failed to list collection names\\.","errorType":"exception","errorClass":"VectorStoreOperationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/azure_cosmos_db.py","lineNumber":1137,"sourceCode":"            embedding_generator=embedding_generator or self.embedding_generator,\n            url=str(self.cosmos_db_nosql_settings.url),\n            key=self.cosmos_db_nosql_settings.key.get_secret_value() if self.cosmos_db_nosql_settings.key else None,\n            cosmos_client=self.cosmos_client,\n            partition_key=None,\n            create_database=self.create_database,\n            env_file_path=None,\n            env_file_encoding=None,\n            **kwargs,\n        )\n\n    @override\n    async def list_collection_names(self, **kwargs) -> Sequence[str]:\n        try:\n            database = await self._get_database_proxy()\n            containers = database.list_containers()\n            return [container[\"id\"] async for container in containers]\n        except Exception as e:\n            raise VectorStoreOperationException(\"Failed to list collection names.\") from e\n\n    @override\n    async def __aexit__(self, exc_type, exc_value, traceback) -> None:\n        \"\"\"Exit the context manager.\"\"\"\n        if self.managed_client:\n            await self.cosmos_client.close()\n","sourceCodeStart":1119,"sourceCodeEnd":1144,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/azure_cosmos_db.py#L1119-L1144","documentation":"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.","triggerScenarios":"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.","commonSituations":"Wrong database name in settings; missing 'read database' permission; the managed cosmos_client was never initialized; or transient connectivity issues to the Cosmos endpoint.","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."],"exampleFix":"// before\nnames = await store.list_collection_names()  # opaque 'Failed to list collection names.'\n// after\ntry:\n    names = await store.list_collection_names()\nexcept VectorStoreOperationException as e:\n    logger.error(\"list failed: %s\", e.__cause__)\n    names = []\n","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions import VectorStoreOperationException\n\ntry:\n    names = await store.list_collection_names()\nexcept VectorStoreOperationException as e:\n    logger.error(\"list_collection_names failed: %s\", e.__cause__)\n    names = []","preventionTips":["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."],"tags":["azure-cosmos-db","collection-management","runtime"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}