microsoft/semantic-kernel · error · ServiceResourceNotFoundError
Record with key '{key}' does not exist
Error message
Record with key '{key}' does not exist What it means
Raised in PineconeMemoryStore.get() when collection.fetch([key]) returns an empty vectors map (len(fetch_response.vectors) == 0). ServiceResourceNotFoundError indicates the specific record key is absent even though the collection exists.
Source
Thrown at python/semantic_kernel/connectors/memory_stores/pinecone/pinecone_memory_store.py:244
async def get(self, collection_name: str, key: str, with_embedding: bool = False) -> MemoryRecord:
"""Gets a record.
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.
"""
if not await self.does_collection_exist(collection_name):
raise ServiceResourceNotFoundError(f"Collection '{collection_name}' does not exist")
collection = self.pinecone.Index(collection_name)
fetch_response = collection.fetch([key])
if len(fetch_response.vectors) == 0:
raise ServiceResourceNotFoundError(f"Record with key '{key}' does not exist")
return parse_payload(fetch_response.vectors[key], 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.
"""
if not await self.does_collection_exist(collection_name):
raise ServiceResourceNotFoundError(f"Collection '{collection_name}' does not exist")View on GitHub (pinned to c028a0c7dc)
Solutions
- Verify the key was produced by a prior upsert (upsert returns record._id).
- Treat absence as a non-error by catching ServiceResourceNotFoundError and returning None.
- Check the key casing/format against what was stored.
- Use does_collection_exist first to distinguish collection-missing from record-missing.
Example fix
// before
rec = await store.get("my_col", key)
// after
try:
rec = await store.get("my_col", key)
except ServiceResourceNotFoundError:
rec = None Defensive patterns
Strategy: try-catch
Validate before calling
# no pre-check for record existence; fetch is the check — keep the read cheap and handle absence return await store.get(collection_name, key)
Type guard
def is_valid_key(key: str) -> bool:
return isinstance(key, str) and len(key) > 0 Try / catch
from semantic_kernel.exceptions import ServiceResourceNotFoundError
try:
return await store.get(collection_name, key)
except ServiceResourceNotFoundError:
return None # treat missing record as not-found, not an error Prevention
- Treat record-not-found as a normal empty result, not an exception flow, where possible.
- Verify keys come from prior upsert return values.
- Check key formatting/casing against stored ids.
When it happens
Trigger: Fetching a key that was never upserted, was deleted, or is mistyped. The collection exists but the id is unknown.
Common situations: Reading a stale id; the record was removed by remove()/remove_batch(); id format mismatch (e.g., extra prefix/suffix).
Related errors
- Dimensionality of {default_dimensionality} exceeds the maxim
- Failed to create Pinecone settings.
- Dimensionality of {dimension_num} exceeds the maximum allowe
- Collection '{collection_name}' does not exist
- Error upserting record: {upsert_response.message}
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/4eab7f7b2e79b7cb.
Report an issue: GitHub.