From 91f5f862804a2cb5ab4cb65d9634ab9017168a67 Mon Sep 17 00:00:00 2001 From: OlivierDehaene <23298448+OlivierDehaene@users.noreply.github.com> Date: Mon, 14 Nov 2022 14:34:15 +0100 Subject: [PATCH] fix(router): Fix HTTP status codes --- router/src/batcher.rs | 2 +- router/src/validation.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/router/src/batcher.rs b/router/src/batcher.rs index 074c54bc..aacc9634 100644 --- a/router/src/batcher.rs +++ b/router/src/batcher.rs @@ -220,7 +220,7 @@ impl From for (StatusCode, Json) { fn from(err: InferError) -> Self { match err { InferError::GenerationError(_) => ( - StatusCode::INTERNAL_SERVER_ERROR, + StatusCode::FAILED_DEPENDENCY, Json(ErrorResponse { error: err.to_string(), }), diff --git a/router/src/validation.rs b/router/src/validation.rs index 43c246f0..a8437e39 100644 --- a/router/src/validation.rs +++ b/router/src/validation.rs @@ -101,7 +101,7 @@ fn validation_worker( ) { // Loop over requests while let Some((request, response_tx)) = receiver.blocking_recv() { - if request.parameters.temperature < 0.0 { + if request.parameters.temperature <= 0.0 { response_tx .send(Err(ValidationError::Temperature)) .unwrap_or(()); @@ -162,7 +162,7 @@ pub enum ValidationError { impl From for (StatusCode, Json) { fn from(err: ValidationError) -> Self { ( - StatusCode::BAD_REQUEST, + StatusCode::UNPROCESSABLE_ENTITY, Json(ErrorResponse { error: err.to_string(), }),