microsoft/semantic-kernel · error · ValueError
vectorEmbeddings cannot be null or empty in the vector_embed
Error message
vectorEmbeddings cannot be null or empty in the vector_embedding_policy.
What it means
Raised in AzureCosmosDBNoSQLMemoryStore.__init__ when vector_embedding_policy is None or its 'vectorEmbeddings' key maps to an empty list. The vectorEmbeddings array defines the embedding path, dimensions, and data type that Cosmos DB uses to index and search vectors. This check runs after the vectorIndexes check (line 48), so if both policies are invalid you see the vectorIndexes error first.
Source
Thrown at python/semantic_kernel/connectors/memory_stores/azure_cosmosdb_no_sql/azure_cosmosdb_no_sql_memory_store.py:51
partition_key: str = None
vector_embedding_policy: dict[str, Any] | None = None
indexing_policy: dict[str, Any] | None = None
cosmos_container_properties: dict[str, Any] | None = None
def __init__(
self,
cosmos_client: CosmosClient,
database_name: str,
partition_key: str,
vector_embedding_policy: dict[str, Any] | None = None,
indexing_policy: dict[str, Any] | None = None,
cosmos_container_properties: dict[str, Any] | None = None,
):
"""Initializes a new instance of the AzureCosmosDBNoSQLMemoryStore class."""
if indexing_policy["vectorIndexes"] is None or len(indexing_policy["vectorIndexes"]) == 0:
raise ValueError("vectorIndexes cannot be null or empty in the indexing_policy.")
if vector_embedding_policy is None or len(vector_embedding_policy["vectorEmbeddings"]) == 0:
raise ValueError("vectorEmbeddings cannot be null or empty in the vector_embedding_policy.")
self.cosmos_client = cosmos_client
self.database_name = database_name
self.partition_key = partition_key
self.vector_embedding_policy = vector_embedding_policy
self.indexing_policy = indexing_policy
self.cosmos_container_properties = cosmos_container_properties
@override
async def create_collection(self, collection_name: str) -> None:
# Create the database if it already doesn't exist
self.database = await self.cosmos_client.create_database_if_not_exists(id=self.database_name)
# Create the collection if it already doesn't exist
self.container = await self.database.create_container_if_not_exists(
id=collection_name,
partition_key=self.cosmos_container_properties["partition_key"],
indexing_policy=self.indexing_policy,View on GitHub (pinned to c028a0c7dc)
Solutions
- Pass a vector_embedding_policy with a populated vectorEmbeddings list, e.g. {'vectorEmbeddings': [{'path': '/embedding', 'dataType': 'float32', 'dimensions': 1536, 'distanceFunction': 'cosine'}]}.
- Make sure 'dimensions' matches the output dimension of your embedding model and 'path' matches the indexing_policy vectorIndexes path.
- If building the policy from env/config, validate the dict shape before passing it to the constructor.
- Migrate to the non-deprecated AzureCosmosDBNoSQLStore / Collection classes recommended by the @deprecated marker.
Example fix
// before
store = AzureCosmosDBNoSQLMemoryStore(
cosmos_client=client,
database_name='db',
partition_key='/pk',
vector_embedding_policy=None, # triggers ValueError
indexing_policy={'vectorIndexes': [{'path': '/embedding', 'type': 'diskANN'}]},
)
// after
vector_embedding_policy = {
'vectorEmbeddings': [{
'path': '/embedding',
'dataType': 'float32',
'dimensions': 1536,
'distanceFunction': 'cosine',
}]
}
store = AzureCosmosDBNoSQLMemoryStore(
cosmos_client=client,
database_name='db',
partition_key='/pk',
vector_embedding_policy=vector_embedding_policy,
indexing_policy={'vectorIndexes': [{'path': '/embedding', 'type': 'diskANN'}]},
) Defensive patterns
Strategy: validation
Validate before calling
def validate_vector_embedding_policy(policy: dict | None) -> None:
if policy is None:
raise ValueError('vector_embedding_policy must not be None')
ve = policy.get('vectorEmbeddings')
if ve is None or len(ve) == 0:
raise ValueError('vector_embedding_policy["vectorEmbeddings"] must be non-empty')
validate_vector_embedding_policy(vector_embedding_policy) Type guard
from typing import Any
def is_valid_vector_embedding_policy(policy: Any) -> bool:
return (
isinstance(policy, dict)
and isinstance(policy.get('vectorEmbeddings'), list)
and len(policy['vectorEmbeddings']) > 0
) Try / catch
try:
store = AzureCosmosDBNoSQLMemoryStore(
..., vector_embedding_policy=vector_embedding_policy
)
except ValueError as e:
logging.error('Invalid vector embedding policy: %s', e)
raise Prevention
- Never leave vector_embedding_policy as the default None.
- Ensure dimensions match your embedding model output.
- Validate the policy dict in config-loading code.
- Align the embedding path with the indexing_policy vectorIndexes path.
When it happens
Trigger: Constructing AzureCosmosDBNoSQLMemoryStore with vector_embedding_policy=None (the default) or vector_embedding_policy={'vectorEmbeddings': []}. Because the None branch short-circuits with 'or' before subscripting, passing None does reach the ValueError rather than a TypeError here.
Common situations: Forgetting to pass vector_embedding_policy because it defaults to None. Providing a policy dict from a config file where the vectorEmbeddings array was stripped or never populated. Dimension/path mismatch between the embedding policy and the indexing policy.
Related errors
- vectorIndexes cannot be null or empty in the indexing_policy
- Failed to create OpenAI settings.
- Failed to create OpenAI settings.
- Failed to create OpenAI settings.
- Invalid kernel selection. {selectedKernelName} is not a vali
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/e574d8812aad014c.
Report an issue: GitHub.