From 642a5c0a876ce7aa5205b290a7427d0b65b02e2f Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Tue, 29 Sep 2026 23:25:19 -0600 Subject: [PATCH] fix(readarr): tolerate book payloads that omit the grabbed flag --- src/models/readarr_models.rs | 1 + src/models/readarr_models_tests.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/models/readarr_models.rs b/src/models/readarr_models.rs index 0f4cf4ac..c43963b6 100644 --- a/src/models/readarr_models.rs +++ b/src/models/readarr_models.rs @@ -280,6 +280,7 @@ pub struct Book { pub ratings: Option, pub release_date: Option>, pub statistics: Option, + #[serde(default)] pub grabbed: bool, } diff --git a/src/models/readarr_models_tests.rs b/src/models/readarr_models_tests.rs index 0fd62ebf..5a0512fa 100644 --- a/src/models/readarr_models_tests.rs +++ b/src/models/readarr_models_tests.rs @@ -939,6 +939,22 @@ mod tests { assert_none!(&book.statistics); } + #[test] + fn test_book_deserialization_defaults_grabbed_when_absent() { + let book_json = json!({ + "id": 1, + "title": "The Name of the Wind", + "authorId": 3, + "foreignBookId": "test-foreign-book-id", + "monitored": true + }); + + let book: Book = serde_json::from_value(book_json).unwrap(); + + assert!(!book.grabbed); + assert!(book.monitored); + } + #[test] fn test_edition_deserialization() { let edition_json = json!({