microsoft/semantic-kernel · error · MemoryConnectorInitializationError

Database Name cannot be empty.

Error message

Database Name cannot be empty.

What it means

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.)

Source

Thrown at python/semantic_kernel/connectors/memory_stores/azure_cosmosdb/azure_cosmos_db_memory_store.py:68

    def __init__(
        self,
        cosmosStore: AzureCosmosDBStoreApi,
        database_name: str,
        index_name: str,
        vector_dimensions: int,
        num_lists: int = 100,
        similarity: CosmosDBSimilarityType = CosmosDBSimilarityType.COS,
        kind: CosmosDBVectorSearchType = CosmosDBVectorSearchType.VECTOR_HNSW,
        m: int = 16,
        ef_construction: int = 64,
        ef_search: int = 40,
    ):
        """Initializes a new instance of the AzureCosmosDBMemoryStore class."""
        if vector_dimensions <= 0:
            raise MemoryConnectorInitializationError("Vector dimensions must be a positive number.")
        if database_name is None:
            raise MemoryConnectorInitializationError("Database Name cannot be empty.")
        if index_name is None:
            raise MemoryConnectorInitializationError("Index Name cannot be empty.")

        self.cosmos_store = cosmosStore
        self.index_name = index_name
        self.num_lists = num_lists
        self.similarity = similarity
        self.kind = kind
        self.m = m
        self.ef_construction = ef_construction
        self.ef_search = ef_search

    @staticmethod
    async def create(
        database_name: str,
        collection_name: str,
        vector_dimensions: int,
        num_lists: int,

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Pass a non-None `database_name` that exists in your Cosmos account.
  2. Populate the config/env var backing the database name before construction.
  3. Add your own pre-check for empty-string too, since the library only rejects None.

Example fix

// before
store = AzureCosmosDBMemoryStore(cosmos_store, None, "idx", vector_dimensions=1536)

// after
store = AzureCosmosDBMemoryStore(cosmos_store, "my-database", "idx", vector_dimensions=1536)
Defensive patterns

Strategy: validation

Validate before calling

def valid_db_name(name) -> bool:
    # library only checks None; also guard empty strings yourself
    return isinstance(name, str) and name.strip() != ""

# assert valid_db_name(database_name) before constructing the store

Type guard

def is_non_empty_str(name) -> bool:
    return isinstance(name, str) and name.strip() != ""

Try / catch

from semantic_kernel.exceptions import MemoryConnectorInitializationError
try:
    store = AzureCosmosDBMemoryStore(cs, database_name, "idx", vector_dimensions=1536)
except MemoryConnectorInitializationError as e:
    if "Database Name" in str(e):
        raise SystemExit("provide a non-empty database_name") from e
    raise

Prevention

When it happens

Trigger: Constructing the store with `database_name=None` (e.g. omitted from config, or a config read that returned None).

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

Related errors


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