Skip to content

Commit 04bc198

Browse files
fix(MonitorThresholds): treat empty string as null for f64 threshold fields (#1292)
Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 17b18df commit 04bc198

80 files changed

Lines changed: 354 additions & 263 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.generator/src/generator/templates/model_simple.j2

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ impl<'de> Deserialize<'de> for {{ name }} {
126126
{%- set dataType = get_type(schema, alternative_name=name + propertyName, render_option=false, version=version) %}
127127
"{{ attr }}" => {
128128
{%- if not nullable and not required %}
129-
if v.is_null() {
129+
if v.is_null(){% if schema.get("type") == "number" %} || v.as_str() == Some(""){% endif %} {
130+
continue;
131+
}
132+
{%- elif nullable and schema.get("type") == "number" %}
133+
if v.as_str() == Some("") {
130134
continue;
131135
}
132136
{%- endif %}

src/datadogV1/model/model_host_metrics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,19 @@ impl<'de> Deserialize<'de> for HostMetrics {
9797
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
9898
match k.as_str() {
9999
"cpu" => {
100-
if v.is_null() {
100+
if v.is_null() || v.as_str() == Some("") {
101101
continue;
102102
}
103103
cpu = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
104104
}
105105
"iowait" => {
106-
if v.is_null() {
106+
if v.is_null() || v.as_str() == Some("") {
107107
continue;
108108
}
109109
iowait = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
110110
}
111111
"load" => {
112-
if v.is_null() {
112+
if v.is_null() || v.as_str() == Some("") {
113113
continue;
114114
}
115115
load = Some(serde_json::from_value(v).map_err(M::Error::custom)?);

src/datadogV1/model/model_hourly_usage_attribution_body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl<'de> Deserialize<'de> for HourlyUsageAttributionBody {
202202
tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
203203
}
204204
"total_usage_sum" => {
205-
if v.is_null() {
205+
if v.is_null() || v.as_str() == Some("") {
206206
continue;
207207
}
208208
total_usage_sum =

src/datadogV1/model/model_logs_index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<'de> Deserialize<'de> for LogsIndex {
177177
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
178178
}
179179
"daily_limit_warning_threshold_percentage" => {
180-
if v.is_null() {
180+
if v.is_null() || v.as_str() == Some("") {
181181
continue;
182182
}
183183
daily_limit_warning_threshold_percentage =

src/datadogV1/model/model_logs_index_update_request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<'de> Deserialize<'de> for LogsIndexUpdateRequest {
177177
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
178178
}
179179
"daily_limit_warning_threshold_percentage" => {
180-
if v.is_null() {
180+
if v.is_null() || v.as_str() == Some("") {
181181
continue;
182182
}
183183
daily_limit_warning_threshold_percentage =

src/datadogV1/model/model_metrics_query_unit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<'de> Deserialize<'de> for MetricsQueryUnit {
135135
plural = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
136136
}
137137
"scale_factor" => {
138-
if v.is_null() {
138+
if v.is_null() || v.as_str() == Some("") {
139139
continue;
140140
}
141141
scale_factor =

src/datadogV1/model/model_monitor_thresholds.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,25 +143,40 @@ impl<'de> Deserialize<'de> for MonitorThresholds {
143143
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
144144
match k.as_str() {
145145
"critical" => {
146-
if v.is_null() {
146+
if v.is_null() || v.as_str() == Some("") {
147147
continue;
148148
}
149149
critical = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
150150
}
151151
"critical_recovery" => {
152+
if v.as_str() == Some("") {
153+
continue;
154+
}
152155
critical_recovery =
153156
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
154157
}
155158
"ok" => {
159+
if v.as_str() == Some("") {
160+
continue;
161+
}
156162
ok = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
157163
}
158164
"unknown" => {
165+
if v.as_str() == Some("") {
166+
continue;
167+
}
159168
unknown = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
160169
}
161170
"warning" => {
171+
if v.as_str() == Some("") {
172+
continue;
173+
}
162174
warning = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
163175
}
164176
"warning_recovery" => {
177+
if v.as_str() == Some("") {
178+
continue;
179+
}
165180
warning_recovery =
166181
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
167182
}

0 commit comments

Comments
 (0)