microsoft/semantic-kernel · warning · MemoryConnectorResourceNotFound
Memory record not found
Error message
Memory record not found
What it means
Raised in `AzureCognitiveSearchMemoryStore.get` when the Azure Search `get_document` call throws `ResourceNotFoundError` (the document key does not exist in the index). The search client is closed and the exception is re-raised as `MemoryConnectorResourceNotFound` (chained via `from exc`). It is the equivalent of a key-not-found for this store.
Source
Thrown at python/semantic_kernel/connectors/memory_stores/azure_cognitive_search/azure_cognitive_search_memory_store.py:285
Args:
collection_name (str): The name of the collection to get the record from.
key (str): The unique database key of the record.
with_embedding (bool): Whether to include the embedding in the result. (default: {False})
Returns:
MemoryRecord: The record.
"""
# Look up Search client class to see if exists or create
search_client = self._search_index_client.get_search_client(collection_name.lower())
try:
search_result = await search_client.get_document(
key=encode_id(key), selected_fields=get_field_selection(with_embedding)
)
except ResourceNotFoundError as exc:
await search_client.close()
raise MemoryConnectorResourceNotFound("Memory record not found") from exc
await search_client.close()
# Create Memory record from document
return dict_to_memory_record(search_result, with_embedding)
async def get_batch(
self, collection_name: str, keys: list[str], with_embeddings: bool = False
) -> list[MemoryRecord]:
"""Gets a batch of records.
Args:
collection_name (str): The name of the collection to get the records from.
keys (List[str]): The unique database keys of the records.
with_embeddings (bool): Whether to include the embeddings in the results. (default: {False})
Returns:
List[MemoryRecord]: The records.View on GitHub (pinned to c028a0c7dc)
Solutions
- Confirm the record was upserted into that index and the key matches (account for `encode_id`).
- Catch `MemoryConnectorResourceNotFound` to handle missing records gracefully.
- Account for indexing latency: retry shortly after a fresh upsert, or check the index is ready.
- Verify you query the same collection/index name used at write time.
Example fix
// before
rec = await store.get("idx", key) # MemoryConnectorResourceNotFound
// after
from semantic_kernel.exceptions import MemoryConnectorResourceNotFound
try:
rec = await store.get("idx", key)
except MemoryConnectorResourceNotFound:
rec = None Defensive patterns
Strategy: try-catch
Validate before calling
# optional existence pre-check via batch (does not raise on miss)
async def acs_exists_or_none(store, collection, key):
recs = await store.get_batch(collection, [key], with_embeddings=False)
return recs[0] if recs else None Try / catch
from semantic_kernel.exceptions import MemoryConnectorResourceNotFound
try:
rec = await store.get("idx", key)
except MemoryConnectorResourceNotFound:
rec = None Prevention
- Catch `MemoryConnectorResourceNotFound` to treat missing records as normal control flow.
- Use `get_batch` when missing keys are expected.
- Account for `encode_id` and Azure Search indexing lag after upserts.
- Confirm the key/collection used at read matches the write.
When it happens
Trigger: Calling `get(collection_name, key)` for a record whose encoded id (`encode_id(key)`) is not present in the Azure Search index; the record was never upserted, was deleted, or the id encoding differs between write and read.
Common situations: Read before write; querying the wrong index; `encode_id` produces different base64 for the same logical key due to whitespace/encoding changes; record deleted out-of-band; race during indexing lag (Azure Search is eventually consistent).
Related errors
- Record with key '{key}' does not exist
- Agent type '{recipient.type}' does not exist.
- Agent with name {agent_id.type} not found.
- Agent with name {id.type} not found.
- Failed to create Azure Cognitive Search settings.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/358b71efa10e6b1a.
Report an issue: GitHub.