fix: tolerate update records that omit the changes list

The changes field was required, so a single record without it failed the
whole response and emptied the updates list. A live instance returns five
update records of which one has no changes key, so this is reachable rather
than theoretical.

This affects every servarr, since Update is shared.
This commit is contained in:
Dark-Alex-17 committed 2026-08-20 21:06:28 -06:00
1 parent 97d67a6938
commit e0e82e654e
2 files changed
+24

No files matched your search

+1
View File
@@ -354,6 +354,7 @@ pub struct Update {
pub installed: bool,
pub latest: bool,
pub installed_on: Option<DateTime<Utc>>,
#[serde(default)]
pub changes: UpdateChanges,
}
+23
View File
@@ -4,6 +4,7 @@ mod tests {
use crate::models::servarr_models::{
AuthenticationMethod, AuthenticationRequired, CertificateValidation, Indexer, QualityProfile,
Update, UpdateChanges,
};
#[test]
@@ -67,4 +68,26 @@ mod tests {
assert_eq!(expected_quality_profile, quality_profile);
}
#[test]
fn test_update_deserializes_when_changes_is_absent() {
let update_json = r#"{
"version": "0.4.18.2805",
"releaseDate": "2025-06-15T06:22:22Z",
"installed": false,
"latest": true,
"installedOn": "2025-06-22T05:09:11Z"
}"#;
let update = serde_json::from_str::<Update>(update_json);
assert_ok!(&update);
assert_eq!(
update.unwrap().changes,
UpdateChanges {
new: None,
fixed: None,
}
);
}
}