From 1d2dac24696e67fad49b9691b6425908957f545d Mon Sep 17 00:00:00 2001 From: Lachlan Deakin Date: Thu, 25 Jan 2024 21:13:25 +1100 Subject: [PATCH] Fix potential missed error in `Metadata::to_configuration` --- CHANGELOG.md | 1 + src/metadata.rs | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 602a8dfe..72088d98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `FillValue::equals_all` incorrect behaviour with a `FillValue` with size not equal to 1, 2, 4, 8, or 16 bytes. - Fix `NodePath` display output - Fix handling of non-standard `NaN` values for `f16` and `bf16` + - Fix potential missed error in `Metadata::to_configuration` ## [0.10.0] - 2024-01-17 diff --git a/src/metadata.rs b/src/metadata.rs index 1a9a23be..d045c247 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -157,8 +157,9 @@ impl Metadata { )) }, |configuration| { - serde_json::from_value(serde_json::to_value(configuration).unwrap_or_default()) - .map_or_else( + let value = serde_json::to_value(configuration); + match value { + Ok(value) => serde_json::from_value(value).map_or_else( |_| { Err(ConfigurationInvalidError::new( &self.name, @@ -166,7 +167,12 @@ impl Metadata { )) }, |configuration| Ok(configuration), - ) + ), + Err(_) => Err(ConfigurationInvalidError::new( + &self.name, + self.configuration.clone(), + )), + } }, ) }