@@ -28,7 +28,9 @@ use tucana::sagittarius_gateway::execution_service_client::ExecutionServiceClien
2828use tucana:: sagittarius_gateway:: { ExecutionLogonRequest , Logon } ;
2929use tucana:: shared:: { ExecutionFlow , ValidationFlow } ;
3030
31- use crate :: { authorization:: authorization:: get_authentication_metadata, flow:: key_has_flow_id} ;
31+ use crate :: {
32+ authorization:: authorization:: get_authentication_metadata, flow:: key_has_flow_id, validation,
33+ } ;
3234
3335pub struct SagittariusTestExecutionServiceClient {
3436 nats_client : async_nats:: Client ,
@@ -205,8 +207,44 @@ impl SagittariusTestExecutionServiceClient {
205207 }
206208 } ;
207209
208- // TODO: When the new validator is ready, the body needs to be validated at this
209- // point.
210+ if validation:: is_rest_flow ( & validation_flow) {
211+ let input_schema = validation:: extract_input_schema ( & validation_flow) ;
212+ if let Err ( err) = validation:: validate_body_against_schema (
213+ input_schema,
214+ request. body . as_ref ( ) ,
215+ ) {
216+ log:: warn!(
217+ "Rejecting Sagittarius execution request due to input schema validation failure requested_execution_id={} flow_id={} error={}" ,
218+ request. execution_identifier,
219+ request. flow_id,
220+ err
221+ ) ;
222+
223+ let execution_id = if request. execution_identifier . is_empty ( ) {
224+ uuid:: Uuid :: new_v4 ( ) . to_string ( )
225+ } else {
226+ request. execution_identifier . clone ( )
227+ } ;
228+
229+ let rejection = validation:: rejection_result (
230+ execution_id,
231+ request. flow_id ,
232+ & err,
233+ ) ;
234+
235+ if let Err ( status) =
236+ self . response_sender . send_execution_result ( rejection) . await
237+ {
238+ log:: error!(
239+ "Failed to send input schema validation rejection result flow_id={} error={:?}" ,
240+ request. flow_id,
241+ status
242+ ) ;
243+ }
244+
245+ continue ;
246+ }
247+ }
210248
211249 let execution_id = if request. execution_identifier . is_empty ( ) {
212250 uuid:: Uuid :: new_v4 ( ) . to_string ( )
0 commit comments