From 5666522c5c7e957d1951def837306a8d0146169c Mon Sep 17 00:00:00 2001 From: Riya Saxena Date: Mon, 1 Jul 2024 19:27:32 -0700 Subject: [PATCH] set blank response when indexNotFound exception Signed-off-by: Riya Saxena --- .../correlation/alert/CorrelationAlertService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/opensearch/securityanalytics/correlation/alert/CorrelationAlertService.java b/src/main/java/org/opensearch/securityanalytics/correlation/alert/CorrelationAlertService.java index 54c09d29a..e5c43698b 100644 --- a/src/main/java/org/opensearch/securityanalytics/correlation/alert/CorrelationAlertService.java +++ b/src/main/java/org/opensearch/securityanalytics/correlation/alert/CorrelationAlertService.java @@ -26,6 +26,7 @@ import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; +import org.opensearch.index.IndexNotFoundException; import org.opensearch.index.query.BoolQueryBuilder; import org.opensearch.index.query.QueryBuilders; import org.opensearch.index.query.TermsQueryBuilder; @@ -188,7 +189,11 @@ public void getCorrelationAlerts(String ruleId, Table tableProp, ActionListener< }, e -> { log.error("Search request to fetch correlation alerts failed", e); - listener.onFailure(e); + if (e instanceof IndexNotFoundException) { + listener.onResponse(new GetCorrelationAlertsResponse(Collections.emptyList(), 0)); + } else { + listener.onFailure(e); + } } )); }