From 87573d919765e9fe2935bea313d369102e957fc6 Mon Sep 17 00:00:00 2001 From: Jedr Blaszyk Date: Thu, 24 Oct 2024 11:48:50 +0200 Subject: [PATCH] [Bugfix] Gracefully handle non exisiting index when looking for doc by id --- connectors/es/index.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/connectors/es/index.py b/connectors/es/index.py index 6bbe931a4..8ee5c7efb 100644 --- a/connectors/es/index.py +++ b/connectors/es/index.py @@ -217,18 +217,18 @@ async def fetch_by_id(self, doc_id): return self._create_object(resp_body) async def fetch_response_by_id(self, doc_id): - if not self.serverless: - await self._retrier.execute_with_retry( - partial(self.client.indices.refresh, index=self.index_name) - ) - try: + if not self.serverless: + await self._retrier.execute_with_retry( + partial(self.client.indices.refresh, index=self.index_name) + ) + resp = await self._retrier.execute_with_retry( partial(self.client.get, index=self.index_name, id=doc_id) ) except ApiError as e: - logger.critical(f"The server returned {e.status_code}") - logger.critical(e.body, exc_info=True) + logger.error(f"The server returned {e.status_code}") + logger.error(e.body, exc_info=True) if e.status_code == 404: msg = f"Couldn't find document in {self.index_name} by id {doc_id}" raise DocumentNotFoundError(msg) from e