From 5499fe55faa43b0362e75a0df003eaafd321e9d1 Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Wed, 28 Feb 2024 16:24:31 -0500 Subject: [PATCH] add logic to handle unexpected payload --- src/coordinator.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/coordinator.rs b/src/coordinator.rs index a8d5aad..a638b72 100644 --- a/src/coordinator.rs +++ b/src/coordinator.rs @@ -121,15 +121,26 @@ impl Coordinator { let body = message.body.context("Missing message body")?; - let UniquenessCheckRequest { - plain_code: template, + if let Ok(UniquenessCheckRequest { + plain_code, signup_id, - } = serde_json::from_str(&body) - .context("Failed to parse message")?; + }) = serde_json::from_str::(&body) + { + self.uniqueness_check(receipt_handle, plain_code, signup_id) + .await?; + } else { + tracing::error!( + ?receipt_handle, + "Failed to parse template from message" + ); - // Process the query - self.uniqueness_check(receipt_handle, template, signup_id) + sqs_delete_message( + &self.sqs_client, + &self.config.queues.queries_queue_url, + receipt_handle, + ) .await?; + } } Ok(()) }