{"record":{"id":"15e27a8bb2fe8894","repo":"microsoft/semantic-kernel","slug":"index-name-cannot-be-empty","errorCode":null,"errorMessage":"Index Name cannot be empty.","messagePattern":"Index 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":70,"sourceCode":"        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,\n        similarity: CosmosDBSimilarityType,\n        kind: CosmosDBVectorSearchType,","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/azure_cosmosdb/azure_cosmos_db_memory_store.py#L52-L88","documentation":"Constructor guard in `AzureCosmosDBMemoryStore.__init__`: if `index_name is None` it raises `MemoryConnectorInitializationError`. An index (vector index) name is required for vector search configuration, so None is rejected. (As with the database-name check, only `None` is rejected — empty strings pass.)","triggerScenarios":"Constructing the store with `index_name=None` (omitted/unset config value for the vector index name).","commonSituations":"Config field for the index name not set; passing a None variable by mistake; env var absent; argument-ordering error in the constructor call.","solutions":["Pass a non-None `index_name` (the name of the vector index to create/use in Cosmos).","Populate the config/env var backing the index name before construction.","Add your own empty-string check, since the library only guards None."],"exampleFix":"// before\nstore = AzureCosmosDBMemoryStore(cosmos_store, \"db\", None, vector_dimensions=1536)\n\n// after\nstore = AzureCosmosDBMemoryStore(cosmos_store, \"db\", \"vector-index\", vector_dimensions=1536)","handlingStrategy":"validation","validationCode":"def valid_index_name(name) -> bool:\n    return isinstance(name, str) and name.strip() != \"\"\n\n# assert valid_index_name(index_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, \"db\", index_name, vector_dimensions=1536)\nexcept MemoryConnectorInitializationError as e:\n    if \"Index Name\" in str(e):\n        raise SystemExit(\"provide a non-empty index_name\") from e\n    raise","preventionTips":["Pass a non-empty `index_name` for the Cosmos vector index.","Populate the config/env var backing the index 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"}