From e86ecbac63ab8cec773e07549a286a77edaac1d4 Mon Sep 17 00:00:00 2001 From: Olivier Dehaene Date: Tue, 11 Oct 2022 16:53:40 +0200 Subject: [PATCH] ValidationError was not correctly handled --- router/src/server.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/router/src/server.rs b/router/src/server.rs index 14e81709..64b37ff8 100644 --- a/router/src/server.rs +++ b/router/src/server.rs @@ -69,13 +69,15 @@ async fn generate( ) -> poem::Result> { let start = Instant::now(); - let (input_length, validated_request) = validation + let (input_length, validated_request) = match validation .validate(GenerateRequest { inputs: req.inputs.clone(), parameters: req.parameters.clone(), }) - .await - .unwrap(); + .await { + Ok(result) => result, + Err(_) => return Err(poem::Error::from_status(StatusCode::INTERNAL_SERVER_ERROR)) + }; let output = infer.infer(input_length, validated_request).await;