tdlib / telegram-bot-api

Telegram Bot API server
https://core.telegram.org/bots
Boost Software License 1.0
2.94k stars 569 forks source link

[API 7.2] Issues with Mixed-Format Sticker Packs #564

Closed sergix44 closed 2 months ago

sergix44 commented 2 months ago

Hi! I'm one of the nutgram mantainers, while upgrading the framework to support the latest changes, we noticed a bunch of issues related to the new mixed format stickers:

Added the field format to the class InputSticker.

~~Backwards compatibility has been broken: image Idk, might intented to be this way, but if yes, than doesnt make any sense why is not required while adding a sticker to a set: image~~

But a bigger issue is that the API accepts stickers that doesn't match the specified format (are also displayed correctly): image

So, seems the API does not care what format contains, but only requires the format parameter to be present in the request πŸ€”

Added the parameter format to the method setStickerSetThumbnail.

Same here, backwards compatibility has been broken, and a bunch of random errors are given for different combinations of input parameters: image image But when format is specified, seems to work fine: image

cc @Lukasss93

levlam commented 2 months ago

Backward compatibility wasn't broken. Since Bot API 7.2 the field format in InputSticker is mandatory and must be always specified, but you don't pass it. Previously, createNewStickerSet had mandatory parameter sticker_format. You don't pass it either, therefore the request is invalid and isn't expected to succeed.

The format field is required in all methods, including addStickerToSet and setStickerSetThumbnail. If you failed to specify it or specified an incorrect value, then it is hardly possible to predict effect of the request. It can succeed, fail, or succeed, but add a broken sticker to the set.

Lukasss93 commented 2 months ago

Okay, I see what you mean.

Method API 7.1 API 7.2 Breaking change?
createNewStickerSet
sticker_format:βœ…

stickers.*.format:❌

sticker_format:❌

stickers.*.format:βœ…

NO
addStickerToSet sticker.format:❌ sticker.format:❔optional NO
setStickerSetThumbnail format:❌ format:βœ…
⚠️ YES
sergix44 commented 2 months ago

Backward compatibility wasn't broken. Since Bot API 7.2 the field format in InputSticker is mandatory and must be always specified, but you don't pass it. Previously, createNewStickerSet had mandatory parameter sticker_format. You don't pass it either, therefore the request is invalid and isn't expected to succeed.

The format field is required in all methods, including addStickerToSet and setStickerSetThumbnail. If you failed to specify it or specified an incorrect value, then it is hardly possible to predict effect of the request. It can succeed, fail, or succeed, but add a broken sticker to the set.

Yep you right about the the createNewStickerSet call, my bad. But the other stuff is still valid, so in addition the the @Lukasss93 's summary above, what I wanted to point out are the misleading error messages that the api returns in these cases, as well as the lack of validation with respect to the consistency between the uploaded file and the format field.

levlam commented 2 months ago

As for the addStickerToSet method, even though the format parameter is mandatory as you say, it actually works even if it is not passed.

It doesn't always work. It can work in some cases for backward compatibility for old bots. The parameter format is mandatory in InputSticker and must be always passed to ensure that the bot correctly works with mixed-format sticker packs.

setStickerSetThumbnail works for old bots as it worked previously. Backward compatibility is enforced by Bot API and there were no backward compatibility breaking changes for requests in Bot API 7.2.

Lukasss93 commented 2 months ago

I got it. Thank you 😊

sergix44 commented 2 months ago

Thanks

Sithusoelwin35 commented 2 months ago

Yesterday the Telegram team released Bot API 7.2. This update brings many changes, which we are already working on implementing.

However there is one major backward incompatible change, which is the removal of the fields StickerSet.is_animated/is_video. This unfortunately breaks the method Bot.get_sticker_set and affects all versions of our library. The current workaround for this if you have v20.8+ is to directly call await bot.do_api_request("get_sticker_set", {"name": sticker_set_name}) and parse the resulting JSON return value. The upcoming version of the library will address this incompatibility.

Thank you for understanding and being patient.