From 1d936c5cb5d7b976cf39e92845e2219c838c9059 Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Thu, 17 Sep 2026 15:49:12 -0600 Subject: [PATCH] fix(radarr): serialize the credit type under the same key it is read from Radarr sends and accepts the credit type as "type" in both directions, but the field was only renamed for deserialization, so serializing a Credit emitted "creditType" and a to_value round trip could not be read back. Credit is only deserialized in production, so this affects tests and any future serialization of the record, not the live API traffic. --- src/models/radarr_models.rs | 5 +---- src/models/radarr_models_tests.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/models/radarr_models.rs b/src/models/radarr_models.rs index 9e1a5984..a5792855 100644 --- a/src/models/radarr_models.rs +++ b/src/models/radarr_models.rs @@ -127,10 +127,7 @@ pub struct Credit { pub character: Option, pub department: Option, pub job: Option, - #[serde( - rename(deserialize = "type"), - deserialize_with = "super::from_json_or_default" - )] + #[serde(rename = "type", deserialize_with = "super::from_json_or_default")] pub credit_type: CreditType, } diff --git a/src/models/radarr_models_tests.rs b/src/models/radarr_models_tests.rs index 430ce115..7b9e0d6a 100644 --- a/src/models/radarr_models_tests.rs +++ b/src/models/radarr_models_tests.rs @@ -260,6 +260,18 @@ mod tests { ); } + #[test] + fn test_credit_serializes_credit_type_under_the_type_key() { + let credit_json = serde_json::to_value(crew_credit()).unwrap(); + + assert_eq!(credit_json["type"], json!("crew")); + assert_none!(credit_json.get("creditType")); + assert_eq!( + serde_json::from_value::(credit_json).unwrap(), + crew_credit() + ); + } + #[test] fn test_download_record_default_indexer_value() { let json = r#"{