microsoft/semantic-kernel · error · ServiceResponseException
Get failed due to: {e}
Error message
Get failed due to: {e} What it means
Raised as a ServiceResponseException in MilvusMemoryStore.get_batch when self.collections[collection_name].load() or .query() throws any Exception. The load() step pulls collection data into memory and query() executes the filter expression; failures in either are wrapped with the original error chained.
Source
Thrown at python/semantic_kernel/connectors/memory_stores/milvus/milvus_memory_store.py:343
e: _description_
Returns:
List[MemoryRecord]: _description_
"""
# Check if the collection exists
if not utility.has_collection(collection_name):
logger.debug(f"Collection {collection_name} does not exist, cannot get.")
raise ServiceResourceNotFoundError(f"Collection {collection_name} does not exist, cannot get.")
try:
self.collections[collection_name].load()
gets = self.collections[collection_name].query(
expr=f"{SEARCH_FIELD_ID} in {keys}",
output_fields=OUTPUT_FIELDS_W_EMBEDDING if with_embeddings else OUTPUT_FIELDS_WO_EMBEDDING,
)
except Exception as e:
logger.debug(f"Get failed due to: {e}")
raise ServiceResponseException(f"Get failed due to: {e}") from e
return [milvus_dict_to_memoryrecord(get) for get in gets]
async def remove(self, collection_name: str, key: str) -> None:
"""Remove the specified record based on key.
Args:
collection_name (str): Collection to remove from.
key (str): The key to remove.
"""
await self.remove_batch(collection_name=collection_name, keys=[key])
async def remove_batch(self, collection_name: str, keys: list[str]) -> None:
"""Remove multiple records based on keys.
Args:
collection_name (str): Collection to remove from
keys (List[str]): The list of keys.
View on GitHub (pinned to c028a0c7dc)
Solutions
- Inspect the interpolated {e} to distinguish load failures from query/expression failures.
- Ensure keys are valid strings forming a correct Milvus 'in' expression.
- Add a short wait or retry after recent inserts so data is flushed and loaded.
- Check Milvus server memory and query-node health.
Example fix
// before
records = await store.get_batch('docs', keys, with_embeddings=True) # ServiceResponseException
// after
try:
records = await store.get_batch('docs', keys, with_embeddings=True)
except ServiceResponseException as e:
logging.warning('Milvus get failed, retrying: %s', e)
records = [] # or implement backoff retry Defensive patterns
Strategy: try-catch
Validate before calling
def valid_milvus_keys(keys: list[str]) -> bool:
return bool(keys) and all(isinstance(k, str) and k for k in keys)
if not valid_milvus_keys(keys):
raise ValueError('Invalid keys for Milvus query expression') Try / catch
from semantic_kernel.exceptions import ServiceResponseException
for attempt in range(3):
try:
records = await store.get_batch('docs', keys, with_embeddings=True)
break
except ServiceResponseException as e:
if attempt == 2:
raise
await asyncio.sleep(2 ** attempt) Prevention
- Ensure keys form a valid Milvus 'in' expression.
- Allow time for flush/load after recent inserts before querying.
- Monitor Milvus query-node memory to avoid load() failures.
- Implement backoff retry for transient connection errors.
When it happens
Trigger: Milvus .load() fails due to insufficient memory or the collection not being ready. .query() fails due to a malformed filter expression (the f-string builds expr=f'{SEARCH_FIELD_ID} in {keys}'), missing fields, or connection issues.
Common situations: Querying immediately after insert before the data is flushed/indexed. Malformed keys list producing an invalid Milvus expression. Memory pressure causing load() to fail. Network interruption during query.
Related errors
- Upsert failed due to: {e}
- Remove failed due to: {e}
- Search failed: {e}
- Collection {collection_name} does not exist, cannot get.
- Python nodes are not supported in the dotnet runtime.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/ecb72e161b9ff458.
Report an issue: GitHub.