Parse Error: Data did not match any variant of untagged enum TelegramResponse for `getStickerSet`
When using get_sticker_set method I've got RequestError::InvalidJson error with the following description:
err = InvalidJson {
source: Error("data did not match any variant of untagged enum TelegramResponse", line: 0, column: 0),
raw: "{\"ok\":true,\"result\":{\"name\":\"***\",\"title\":\"***\",\"sticker_type\":\"regular\",\"contains_masks\":false,\"stickers\":[{\"width\":512,\"height\":288,\"emoji\":\"\\ud83d\\udcad\",\"set_name\":\"***\",\"is_animated\":false,\"is_video\":false,\"type\":\"regular\",\"thumbnail\":{\"file_id\":\"***\",\"file_unique_id\":\"***\",\"file_size\":7896,\"width\":320,\"height\":180},\"thumb\":{\"file_id\":\"***\",\"file_unique_id\":\"***\",\"file_size\":7896,\"width\":320,\"height\":180},\"file_id\":\"***\",\"file_unique_id\":\"***\",\"file_size\":14572}]}}",
}
Steps to reproduce
let sticker_set = bot.get_sticker_set("my_sticker_name").await.unwrap();
Meta
-
teloxideversion: 0.12.2
Additional context
I think this is a result of a missing #[serde(default)] on StickerKind::Regular::premium_animation: https://github.com/teloxide/teloxide/blob/fb2865b7cc48e19f5431ea65514ed25e2176d98a/crates/teloxide-core/src/types/sticker.rs#L64-L67
But Option<T> should have Default trait impl with None as default value? https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ceaea5c407a5d5eb826aa6b5c3efcf92
@Avimitin this is mostly irrelevant. We use serde via macros, which do not have access to the type information and can't change Deserialize implementation depending on if type implements Default or not. That's why #[serde(default)] annotation exists -- to tell the macros to use the Default impl.
Bot API 7.2 introduces "Mixed-Format Sticker Packs". This change removes is_animated and is_video from StickerSet.
I think it's enough to just remove this line: https://github.com/teloxide/teloxide/blob/384811ab4ba8771e4ff30730bf1b7e14156031b1/crates/teloxide-core/src/types/sticker_set.rs#L22-L26
Is this being worked on? If not I could try to do it
I don't think anyone is working on this, you may go ahead
It seems that the maintainers did not pay attention to this issue 🤔
Fixed by #1040 (right, @syrtcevvi?).
all right