Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Error: Data did not match any variant of untagged enum TelegramResponse for getStickerSet #1038

Open
Avimitin opened this issue Apr 3, 2024 · 7 comments · May be fixed by #1050
Open
Assignees
Labels
C-core crate: teloxide-core FIXME K-bug Kind: bug

Comments

@Avimitin
Copy link

Avimitin commented Apr 3, 2024

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

  • teloxide version: 0.12.2

Additional context

@Avimitin Avimitin added C-core crate: teloxide-core FIXME K-bug Kind: bug labels Apr 3, 2024
@WaffleLapkin
Copy link
Member

I think this is a result of a missing #[serde(default)] on StickerKind::Regular::premium_animation:

Regular {
/// Premium animation for the sticker, if the sticker is premium.
premium_animation: Option<FileMeta>,
},

@Avimitin
Copy link
Author

Avimitin commented Apr 4, 2024

But Option should have Default trait impl with None as default value? https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ceaea5c407a5d5eb826aa6b5c3efcf92

@WaffleLapkin
Copy link
Member

@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.

@avoonix
Copy link

avoonix commented Apr 14, 2024

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:

/// Sticker format shared by all stickers in this set.
#[serde(flatten)]
pub format: StickerFormat,

@avoonix
Copy link

avoonix commented Apr 17, 2024

Is this being worked on? If not I could try to do it

@WaffleLapkin
Copy link
Member

I don't think anyone is working on this, you may go ahead

@avoonix avoonix linked a pull request Apr 18, 2024 that will close this issue
2 tasks
@AH-dark
Copy link

AH-dark commented May 9, 2024

It seems that the maintainers did not pay attention to this issue 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-core crate: teloxide-core FIXME K-bug Kind: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants