diff --git a/keep/providers/elastic_provider/elastic_provider.py b/keep/providers/elastic_provider/elastic_provider.py index 7458c4a004..35296571fa 100644 --- a/keep/providers/elastic_provider/elastic_provider.py +++ b/keep/providers/elastic_provider/elastic_provider.py @@ -8,6 +8,7 @@ import pydantic from elasticsearch import Elasticsearch +from elasticsearch.exceptions import UnsupportedProductError from keep.contextmanager.contextmanager import ContextManager from keep.exceptions.provider_connection_failed import ProviderConnectionFailed @@ -169,6 +170,13 @@ def __initialize_client(self) -> Elasticsearch: # Check if the connection was successful try: es.info() + except UnsupportedProductError: + raise ProviderConnectionFailed( + "Failed to connect to Elasticsearch: the server did not identify itself as " + "Elasticsearch (UnsupportedProductError). This typically happens when connecting " + "to Elasticsearch 7.x with the elasticsearch-py 8.x client. " + "Please upgrade to Elasticsearch 8.x or use elasticsearch-py < 8.0." + ) except Exception as e: raise ProviderConnectionFailed( f"Failed to connect to Elasticsearch: {str(e)}"