From c90b1890ece213dcffd7f0aa89894461507b198c Mon Sep 17 00:00:00 2001 From: Felix Leupold Date: Tue, 2 Jan 2024 14:38:42 +0100 Subject: [PATCH] Fix notify dto (#2227) # Description Notification calls from the driver to solver engines are currently failing due to: > Failed to deserialize the JSON body into the target type: invalid type: map, expected variant identifier at line 1 column 143 I broke this with #2192 where I missed adding the flatten directive on the driver dto. # Changes - [x] Fix dto on both sides (we can no longer deny_unknow_fields due to this [serde bug](https://github.com/serde-rs/serde/issues/1600)) - [x] Warn if the notify call is not successful ## How to test Run e.g. the partial fill colocation test case. See warning before adjusting the dto and now no longer see it. --- crates/driver/src/infra/solver/dto/notification.rs | 1 + crates/driver/src/infra/solver/mod.rs | 4 +++- crates/driver/src/util/http.rs | 12 +++++++++++- crates/solvers/Cargo.toml | 2 +- .../src/api/routes/notify/dto/notification.rs | 2 +- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/crates/driver/src/infra/solver/dto/notification.rs b/crates/driver/src/infra/solver/dto/notification.rs index bb94162650..2d2cc75090 100644 --- a/crates/driver/src/infra/solver/dto/notification.rs +++ b/crates/driver/src/infra/solver/dto/notification.rs @@ -89,6 +89,7 @@ impl Notification { pub struct Notification { auction_id: Option, solution_id: Option, + #[serde(flatten)] kind: Kind, } diff --git a/crates/driver/src/infra/solver/mod.rs b/crates/driver/src/infra/solver/mod.rs index 30db425022..ee43928c99 100644 --- a/crates/driver/src/infra/solver/mod.rs +++ b/crates/driver/src/infra/solver/mod.rs @@ -194,7 +194,9 @@ impl Solver { req = req.header("X-REQUEST-ID", id); } let future = async move { - let _ = util::http::send(SOLVER_RESPONSE_MAX_BYTES, req).await; + if let Err(error) = util::http::send(SOLVER_RESPONSE_MAX_BYTES, req).await { + tracing::warn!(?error, "failed to notify solver"); + } }; tokio::task::spawn(future.in_current_span()); } diff --git a/crates/driver/src/util/http.rs b/crates/driver/src/util/http.rs index d90f289f5b..69e070e485 100644 --- a/crates/driver/src/util/http.rs +++ b/crates/driver/src/util/http.rs @@ -9,7 +9,15 @@ pub async fn send(limit_bytes: usize, req: reqwest::RequestBuilder) -> Result,