Skip to content

Commit

Permalink
Return 409 on duplicate message insert
Browse files Browse the repository at this point in the history
Ensure that we don't return a 5xx when user attempts to
insert a duplicate message (i.e., due to msg-uid conflict)

Fixes #1454
  • Loading branch information
jaymell committed Oct 1, 2024
1 parent 010844c commit b710f94
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/svix-server/src/v1/endpoints/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::{
},
},
db::models::{application, message, messagecontent},
error::{Error, HttpError, Result},
error::{http_error_on_conflict, Error, HttpError, Result},
queue::{MessageTaskBatch, TaskQueueProducer},
v1::utils::{
filter_and_paginate_time_limited, openapi_tag, validation_error, ApplicationMsgPath,
Expand Down Expand Up @@ -360,7 +360,7 @@ pub(crate) async fn create_message_inner(
let (msg, msg_content) = db
.transaction(|txn| {
async move {
let msg = msg.insert(txn).await?;
let msg = msg.insert(txn).await.map_err(http_error_on_conflict)?;
let msg_content = messagecontent::ActiveModel::new(msg.id.clone(), payload);
let msg_content = msg_content.insert(txn).await?;
Ok((msg, msg_content))
Expand Down

0 comments on commit b710f94

Please sign in to comment.