From 6b0f05e3728f7463f99b041b0e12c972f87f9a08 Mon Sep 17 00:00:00 2001 From: Piotr Limanowski Date: Wed, 26 Jun 2024 17:50:13 +0200 Subject: [PATCH] Do not decode iglu json webhook ue_pr paramter on coerce When attempting convering RawEvent into CollectorPayload we previously were convering it through proper JSON decoder. But as this is already manually modified through recovery process we can skip decoding and instead simply pass the JSON. Otherwise we'd need to alter RawEvent to contain `body` field which it is missing. And we cannot. --- .../event/recovery/utils/payload.scala | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/core/src/main/scala/com/snowplowanalytics/snowplow/event/recovery/utils/payload.scala b/core/src/main/scala/com/snowplowanalytics/snowplow/event/recovery/utils/payload.scala index adb0dce..d55f621 100644 --- a/core/src/main/scala/com/snowplowanalytics/snowplow/event/recovery/utils/payload.scala +++ b/core/src/main/scala/com/snowplowanalytics/snowplow/event/recovery/utils/payload.scala @@ -70,19 +70,13 @@ object payload { cp } case e @ Payload.EnrichmentPayload(_, p) if p.vendor == "com.snowplowanalytics.iglu" => - extractData(e) - .flatMap { case (schema, data) => - data - .as[List[NVP]](json.nvpsDecoder) - .map(nvps => querystring.fromNVP(nvps :+ NVP("schema", Some(schema)))) - .leftMap(err => UncoerciblePayload(e, err.toString)) - } - .map { querystring => - val cp = convert(p) - cp.querystring = querystring - cp - } - + extractData(e).map { case (schema, data) => + val cp = convert(p) + cp.body = data.noSpaces + cp.querystring = s"schema=$schema" + cp.contentType = "application/json" + cp + } case Payload.EnrichmentPayload(_, p) => convert(p).asRight case p => Left(UncocoerciblePayload(p.toString, "Unsupported request format")) }