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:
2 files changed
+24
No files matched your search
@@ -354,6 +354,7 @@ pub struct Update {
|
|||||||
pub installed: bool,
|
pub installed: bool,
|
||||||
pub latest: bool,
|
pub latest: bool,
|
||||||
pub installed_on: Option<DateTime<Utc>>,
|
pub installed_on: Option<DateTime<Utc>>,
|
||||||
|
#[serde(default)]
|
||||||
pub changes: UpdateChanges,
|
pub changes: UpdateChanges,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ mod tests {
|
|||||||
|
|
||||||
use crate::models::servarr_models::{
|
use crate::models::servarr_models::{
|
||||||
AuthenticationMethod, AuthenticationRequired, CertificateValidation, Indexer, QualityProfile,
|
AuthenticationMethod, AuthenticationRequired, CertificateValidation, Indexer, QualityProfile,
|
||||||
|
Update, UpdateChanges,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -67,4 +68,26 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(expected_quality_profile, quality_profile);
|
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,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user