Skip to content

Commit

Permalink
Improve warning when harvest item cannot be deserialized
Browse files Browse the repository at this point in the history
This is a band aid fix and not perfect. When I added the `Unknown`
variant to the enum, I wasn't aware that it was used when other variants
fail to deserialize even with `kind: "event"`. So the warning there
was misleading.

It's still not perfect because I ideally want to print more information
on the deseralization failure. And the `kind` strings are duplicated
now. I think in the future, the `HarvestResponse` might have items of
type `{ kind: String, #[serde(flatten)] body: serde_json::Value }` or
something like that. And then we deserialize it manually in a second
step. We will see.
  • Loading branch information
LukasKalbertodt committed May 23, 2024
1 parent afcef24 commit 2a2a885
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions backend/src/sync/harvest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,23 @@ async fn store_in_db(
removed_playlists += 1;
}

HarvestItem::Unknown { kind, .. } => {
warn!("Unknown item of kind '{kind}' in harvest response. \
You might need to update Tobira.");
HarvestItem::Unknown { kind, updated } => {
let known = [
"event",
"event-deleted",
"series",
"series-deleted",
"playlist",
"playlist-deleted",
];

if known.contains(&&*kind) {
warn!("Could not deserialize item in harvest response for \
kind '{kind}' (updated {updated})");
} else {
warn!("Unknown item of kind '{kind}' in harvest response. \
You might need to update Tobira.");
}
}
}
}
Expand Down

0 comments on commit 2a2a885

Please sign in to comment.