Skip to content

Commit

Permalink
Fix potential missed error in Metadata::to_configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Jan 25, 2024
1 parent f642208 commit 1d2dac2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 9 additions & 3 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,22 @@ 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,
self.configuration.clone(),
))
},
|configuration| Ok(configuration),
)
),
Err(_) => Err(ConfigurationInvalidError::new(
&self.name,
self.configuration.clone(),
)),
}
},
)
}
Expand Down

0 comments on commit 1d2dac2

Please sign in to comment.