From ea87ccc807a23d5a8e7e60b9425293d905127446 Mon Sep 17 00:00:00 2001 From: Andrea Diaz Correia Date: Mon, 25 May 2026 23:52:09 -0300 Subject: [PATCH 1/2] fix: return CantDo(NotFound) for missing orders instead of InvalidOrderId --- src/app/admin_take_dispute.rs | 4 +-- src/app/dispute.rs | 2 +- src/util.rs | 63 +++++++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 5 deletions(-) diff --git a/src/app/admin_take_dispute.rs b/src/app/admin_take_dispute.rs index 16803ce8..50e0b0f4 100644 --- a/src/app/admin_take_dispute.rs +++ b/src/app/admin_take_dispute.rs @@ -180,11 +180,11 @@ pub async fn admin_take_dispute_action( // Get order from db using the dispute order id let order = if let Some(order) = Order::by_id(pool, dispute.order_id) .await - .map_err(|_| MostroInternalErr(ServiceError::InvalidOrderId))? + .map_err(|e| MostroInternalErr(ServiceError::DbAccessError(e.to_string())))? { order } else { - return Err(MostroInternalErr(ServiceError::InvalidOrderId)); + return Err(MostroCantDo(CantDoReason::NotFound)); }; // Update dispute fields diff --git a/src/app/dispute.rs b/src/app/dispute.rs index 51c4a76d..27b62a4d 100644 --- a/src/app/dispute.rs +++ b/src/app/dispute.rs @@ -159,7 +159,7 @@ pub async fn dispute_action( let order_id = if let Some(order_id) = msg.get_inner_message_kind().id { order_id } else { - return Err(MostroInternalErr(ServiceError::InvalidOrderId)); + return Err(MostroCantDo(CantDoReason::NotFound)); }; // Check dispute for this order id is yet present. if find_dispute_by_order_id(pool, order_id).await.is_ok() { diff --git a/src/util.rs b/src/util.rs index eb545e1a..e16149ab 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1170,14 +1170,14 @@ pub async fn get_order(msg: &Message, pool: &Pool) -> Result 300 sats From 18ffee971bcf12c24d9525b4d82e2d4c0b13aa1a Mon Sep 17 00:00:00 2001 From: Andrea Diaz Correia Date: Tue, 26 May 2026 00:01:16 -0300 Subject: [PATCH 2/2] fix: format order_id extraction in get_order (no functional change) --- src/util.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/util.rs b/src/util.rs index e16149ab..0d0ae8cb 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1168,9 +1168,7 @@ pub async fn get_dispute(msg: &Message, pool: &Pool) -> Result) -> Result { let order_msg = msg.get_inner_message_kind(); - let order_id = order_msg - .id - .ok_or(MostroCantDo(CantDoReason::NotFound))?; + let order_id = order_msg.id.ok_or(MostroCantDo(CantDoReason::NotFound))?; let order = Order::by_id(pool, order_id) .await .map_err(|e| MostroInternalErr(ServiceError::DbAccessError(e.to_string())))?;