Skip to content

Commit

Permalink
Fix score deserialization (#1855)
Browse files Browse the repository at this point in the history
Fix after #1846

One of the solvers is sending `score: null` and it fails
deserialization. This PR lands on a much simpler logic to support this
edge case.
  • Loading branch information
sunce86 authored Sep 8, 2023
1 parent 688ddb9 commit 70b1ca2
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions crates/shared/src/http_solver/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,7 @@ where
D: Deserializer<'de>,
{
let value: Value = Deserialize::deserialize(deserializer)?;
match &value {
Value::Object(map)
if !map.contains_key("score")
&& !map.contains_key("scoreDiscount")
&& !map.contains_key("success_probability")
&& !map.contains_key("gas_amount") =>
{
Ok(Score::default())
}
_ => serde_json::from_value(value).map_err(serde::de::Error::custom),
}
Ok(serde_json::from_value(value).unwrap_or(Score::default()))
}

impl Score {
Expand Down

0 comments on commit 70b1ca2

Please sign in to comment.