{"record":{"id":"776f06c2a0d84ce0","repo":"microsoft/semantic-kernel","slug":"database-name-cannot-be-empty","errorCode":null,"errorMessage":"Database Name cannot be empty.","messagePattern":"Database Name cannot be empty\\.","errorType":"validation","errorClass":"MemoryConnectorInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/azure_cosmosdb/azure_cosmos_db_memory_store.py","lineNumber":68,"sourceCode":"\n    def __init__(\n        self,\n        cosmosStore: AzureCosmosDBStoreApi,\n        database_name: str,\n        index_name: str,\n        vector_dimensions: int,\n        num_lists: int = 100,\n        similarity: CosmosDBSimilarityType = CosmosDBSimilarityType.COS,\n        kind: CosmosDBVectorSearchType = CosmosDBVectorSearchType.VECTOR_HNSW,\n        m: int = 16,\n        ef_construction: int = 64,\n        ef_search: int = 40,\n    ):\n        \"\"\"Initializes a new instance of the AzureCosmosDBMemoryStore class.\"\"\"\n        if vector_dimensions <= 0:\n            raise MemoryConnectorInitializationError(\"Vector dimensions must be a positive number.\")\n        if database_name is None:\n            raise MemoryConnectorInitializationError(\"Database Name cannot be empty.\")\n        if index_name is None:\n            raise MemoryConnectorInitializationError(\"Index Name cannot be empty.\")\n\n        self.cosmos_store = cosmosStore\n        self.index_name = index_name\n        self.num_lists = num_lists\n        self.similarity = similarity\n        self.kind = kind\n        self.m = m\n        self.ef_construction = ef_construction\n        self.ef_search = ef_search\n\n    @staticmethod\n    async def create(\n        database_name: str,\n        collection_name: str,\n        vector_dimensions: int,\n        num_lists: int,","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/azure_cosmosdb/azure_cosmos_db_memory_store.py#L50-L86","documentation":"Constructor guard in `AzureCosmosDBMemoryStore.__init__`: if `database_name is None` it raises `MemoryConnectorInitializationError`. The store needs a concrete database name to operate, so a None name is rejected. (Note: the message says 'empty' but the check is only for `None`, not for empty strings.)","triggerScenarios":"Constructing the store with `database_name=None` (e.g. omitted from config, or a config read that returned None).","commonSituations":"Config field for the Cosmos database name not set; passing the wrong variable that resolved to None; relying on an env var that is absent; constructor argument ordering mistake.","solutions":["Pass a non-None `database_name` that exists in your Cosmos account.","Populate the config/env var backing the database name before construction.","Add your own pre-check for empty-string too, since the library only rejects None."],"exampleFix":"// before\nstore = AzureCosmosDBMemoryStore(cosmos_store, None, \"idx\", vector_dimensions=1536)\n\n// after\nstore = AzureCosmosDBMemoryStore(cosmos_store, \"my-database\", \"idx\", vector_dimensions=1536)","handlingStrategy":"validation","validationCode":"def valid_db_name(name) -> bool:\n    # library only checks None; also guard empty strings yourself\n    return isinstance(name, str) and name.strip() != \"\"\n\n# assert valid_db_name(database_name) before constructing the store","typeGuard":"def is_non_empty_str(name) -> bool:\n    return isinstance(name, str) and name.strip() != \"\"","tryCatchPattern":"from semantic_kernel.exceptions import MemoryConnectorInitializationError\ntry:\n    store = AzureCosmosDBMemoryStore(cs, database_name, \"idx\", vector_dimensions=1536)\nexcept MemoryConnectorInitializationError as e:\n    if \"Database Name\" in str(e):\n        raise SystemExit(\"provide a non-empty database_name\") from e\n    raise","preventionTips":["Pass a non-empty `database_name` that exists in your Cosmos account.","Populate the config/env var backing the name before construction.","Guard empty strings yourself since the library only checks None."],"tags":["azure-cosmos-db","validation","config","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}