Skip to content

Commit

Permalink
index not found exception response as emptylist for correlations
Browse files Browse the repository at this point in the history
Signed-off-by: Riya Saxena <[email protected]>
  • Loading branch information
riysaxen-amzn committed Jul 1, 2024
1 parent 2a5cd34 commit a738936
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -40,6 +41,8 @@
import org.opensearch.securityanalytics.action.AckCorrelationAlertsResponse;
import org.opensearch.securityanalytics.action.GetCorrelationAlertsResponse;
import org.opensearch.securityanalytics.util.CorrelationIndices;
import org.opensearch.securityanalytics.util.CorrelationRuleIndices;

import java.io.IOException;
import java.time.Instant;
import java.util.List;
Expand Down Expand Up @@ -188,7 +191,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);
}
}
));
}
Expand Down

0 comments on commit a738936

Please sign in to comment.