Skip to content

get_chat crashes when Telegram returns unique_gift_colors #2568

@alragi0

Description

@alragi0

Environment

  • OS: Windows 11 (64-bit)
  • Python: 3.11.x (installation path: C:\Users\JC\AppData\Roaming\Python\Python314)
  • pyTelegramBotAPI: 4.31.0
  • Bot: long-polling worker running main1.py

Steps to Reproduce

  1. Register a handler that calls bot.get_chat(call.from_user.id) inside a callback query worker.
  2. Run the bot and trigger the handler from a user/chat that exposes the new Telegram field unique_gift_colors.
  3. Observe the worker thread.

Actual Result
bot.get_chat raises NotImplementedError inside telebot.types.UniqueGiftColors.de_json because the library tries to parse unique_gift_colors but the dataclass has not been implemented yet. The worker thread crashes with the following stack trace:

Traceback (most recent call last):
  File "e:\my\starmarket bot\main1.py", line 5219, in worker
    chat = bot.get_chat(call.from_user.id)
  File "C:\Users\JC\AppData\Roaming\Python\Python314\site-packages\telebot\__init__.py", line 1572, in get_chat
    return types.ChatFullInfo.de_json(
        apihelper.get_chat(self.token, chat_id)
    )
  File "C:\Users\JC\AppData\Roaming\Python\Python314\site-packages\telebot\types.py", line 804, in de_json
    obj['unique_gift_colors'] = UniqueGiftColors.de_json(obj['unique_gift_colors'])
  File "C:\Users\JC\AppData\Roaming\Python\Python314\site-packages\telebot\types.py", line 89, in de_json
    raise NotImplementedError
NotImplementedError

Expected Result
bot.get_chat should deserialize ChatFullInfo even when the Telegram Bot API includes unique_gift_colors, or ignore that field until support ships, instead of raising NotImplementedError.

Additional Notes

  • The error started appearing after Telegram added unique_gift_colors to ChatFullInfo. No local code touches that field.
  • Temporary workaround is to avoid calling get_chat for chats that include unique_gift_colors, but an official fix is required in telebot.types.UniqueGiftColors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions