From 8c4fc368da8a1c00e2b5be0990ee2a157fa94470 Mon Sep 17 00:00:00 2001 From: Annie Lee Date: Thu, 24 Mar 2022 15:02:05 -0700 Subject: [PATCH] Update TransportGetFindingsSearchAction.kt --- .../alerting/transport/TransportGetFindingsSearchAction.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetFindingsSearchAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetFindingsSearchAction.kt index 27e610523..0f7e37f9a 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetFindingsSearchAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetFindingsSearchAction.kt @@ -19,6 +19,7 @@ import org.opensearch.alerting.action.GetFindingsSearchRequest import org.opensearch.alerting.action.GetFindingsSearchResponse import org.opensearch.alerting.elasticapi.addFilter import org.opensearch.alerting.model.Finding +import org.opensearch.alerting.model.FindingDocument import org.opensearch.alerting.settings.AlertingSettings import org.opensearch.alerting.util.AlertingException import org.opensearch.client.Client @@ -207,7 +208,11 @@ class TransportGetFindingsSearchAction @Inject constructor( log.info("response: $response") if (!response.isSourceEmpty) { log.info("response not empty") - val parsed = FindingDocument.parse(xcp, response.getSourceAsString) + val xcp = XContentFactory.xContent(XContentType.JSON) + .createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, response.getSourceAsString()) + log.info("created document parser") + XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, xcp.nextToken(), xcp) + val parsed = FindingDocument.parse(xcp, documentId) log.info("Parsed doc: $parsed") } // actionListener.onResponse(GetFindingsSearchResponse(RestStatus.OK, totalFindingCount, findings))