Skip to content

Commit e5f01a1

Browse files
fix: handle unknown metric types in API responses (#40)
* fix: handle unknown metric types in API responses Add serde(other) catch-all variant to MetricType enum so the CLI gracefully handles new metric types added to the backend API without crashing on deserialization. * fix: display unknown metric types as BUILT_IN
1 parent b97d894 commit e5f01a1

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/client/models/metric.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ pub enum MetricType {
7979
#[serde(rename = "METRIC_COMPOSITE_EVALUATION")]
8080
#[value(name = "composite")]
8181
CompositeEvaluation,
82+
#[serde(other)]
83+
#[value(skip)]
84+
Unknown,
8285
}
8386

8487
impl std::fmt::Display for MetricType {
@@ -95,6 +98,7 @@ impl std::fmt::Display for MetricType {
9598
Self::Regex => write!(f, "REGEX"),
9699
Self::Pause => write!(f, "PAUSE"),
97100
Self::CompositeEvaluation => write!(f, "COMPOSITE"),
101+
Self::Unknown => write!(f, "BUILT_IN"),
98102
}
99103
}
100104
}

0 commit comments

Comments
 (0)