Skip to content

Commit

Permalink
add logic to handle unexpected payload
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKitsune committed Feb 28, 2024
1 parent eb24fee commit 5499fe5
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<UniquenessCheckRequest>(&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(())
}
Expand Down

0 comments on commit 5499fe5

Please sign in to comment.