From ff768788e0ed0826a11ec0f1def432f3bb73be8b Mon Sep 17 00:00:00 2001 From: liferoad Date: Fri, 3 Oct 2025 21:23:43 -0400 Subject: [PATCH] fix: handle empty requests in milvus search to avoid connection attempts Prevent unnecessary connection attempts by returning early when receiving empty requests --- sdks/python/apache_beam/ml/rag/enrichment/milvus_search.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sdks/python/apache_beam/ml/rag/enrichment/milvus_search.py b/sdks/python/apache_beam/ml/rag/enrichment/milvus_search.py index a0f597f5366f..e35d31cc8a5d 100644 --- a/sdks/python/apache_beam/ml/rag/enrichment/milvus_search.py +++ b/sdks/python/apache_beam/ml/rag/enrichment/milvus_search.py @@ -417,6 +417,9 @@ def __enter__(self): def __call__(self, request: Union[Chunk, List[Chunk]], *args, **kwargs) -> List[Tuple[Chunk, Dict[str, Any]]]: reqs = request if isinstance(request, list) else [request] + # Early return for empty requests to avoid unnecessary connection attempts + if not reqs: + return [] search_result = self._search_documents(reqs) return self._get_call_response(reqs, search_result)