From 9af3a4aa89fc13a8a546d263a8f9e046fed47fe5 Mon Sep 17 00:00:00 2001 From: Amp Date: Mon, 24 Aug 2026 20:45:09 +0000 Subject: [PATCH] fix(api): box tenant limit rejection responses Amp-Thread-ID: https://ampcode.com/threads/T-01a03558-2154-7552-8a14-b14c6c9b2d63 Co-authored-by: Jonathan Haas --- crates/sandboxwich-api/src/limits.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/sandboxwich-api/src/limits.rs b/crates/sandboxwich-api/src/limits.rs index 28f6ff86..eca0aff5 100644 --- a/crates/sandboxwich-api/src/limits.rs +++ b/crates/sandboxwich-api/src/limits.rs @@ -70,7 +70,7 @@ pub(crate) async fn enforce_tenant_limits( ) .await { - return response; + return *response; } if is_mutating(request.method()) && let Err(response) = consume( @@ -82,7 +82,7 @@ pub(crate) async fn enforce_tenant_limits( ) .await { - return response; + return *response; } next.run(request).await } @@ -100,7 +100,7 @@ async fn consume( kind: CounterKind, limit: u32, window_seconds: u32, -) -> Result<(), Response> { +) -> Result<(), Box> { let now = Utc::now(); let expires = now + ChronoDuration::seconds(i64::from(window_seconds)); let sql = format!( @@ -125,7 +125,7 @@ async fn consume( .bind(i64::from(limit)) .fetch_optional(&db.pool) .await - .map_err(|error| ApiError::from(error).into_response())?; + .map_err(|error| Box::new(ApiError::from(error).into_response()))?; if row.is_some() { return Ok(()); } @@ -150,7 +150,7 @@ async fn consume( HeaderValue::from_str(&retry_after.to_string()) .expect("positive seconds are a valid header"), ); - Err(response) + Err(Box::new(response)) } async fn counter_retry_after(db: &Database, tenant: &str, kind: CounterKind) -> Option {