question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error processing `ChatMemberRestricted`

See original GitHub issue

Checklist

  • I am sure the error is coming from aiogram code
  • I have searched in the issue tracker for similar bug reports, including closed ones

Operating system

Any (tested on Ubuntu+Windows)

Python version

python3.8-3.10 (tested on all three)

aiogram version

3.0.0a18 + 3.0.0b4 (tested on those two)

Expected behavior

Processing update and passing it to handlers (or at least not raising an error and exiting program)

Current behavior

Exiting the program with given traceback: https://paste.aiogram.dev/ovabufiwar.properties

Steps to reproduce

Unfortunately, I don’t know what happened to TG to send updates like this one.

Code example

import asyncio

from aiogram import Dispatcher, Bot, Router
from aiogram.types import CallbackQuery, Message


router = Router()


@router.message()
async def handler(msg: Message):
    pass


@router.callback_query()
async def handler(call: CallbackQuery):
    pass


dp = Dispatcher()
bot = Bot("BOT_TOKEN")
dp.include_router(router)


async def main() -> None:
    await dp.start_polling(bot)


if __name__ == "__main__":
    asyncio.run(main())

Logs

Traceback (most recent call last):
  File "D:\Code\wqe\main.py", line 58, in <module>
    loop.run_until_complete(main())
  File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "D:\Code\wqe\main.py", line 47, in main
    await dp.start_polling(bot)
  File "D:\Code\wqe\.venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 396, in start_polling
    await asyncio.gather(*coro_list)
  File "D:\Code\wqe\.venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 266, in _polling
    async for update in self._listen_updates(
  File "D:\Code\wqe\.venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 149, in _listen_updates
    updates = await bot(get_updates, **kwargs)
  File "D:\Code\wqe\.venv\lib\site-packages\aiogram\client\bot.py", line 336, in __call__
    return await self.session(self, method, timeout=request_timeout)
  File "D:\Code\wqe\.venv\lib\site-packages\aiogram\client\session\base.py", line 192, in __call__
    return await middleware(bot, method)
  File "D:\Code\wqe\.venv\lib\site-packages\aiogram\client\session\aiohttp.py", line 153, in make_request
    response = self.check_response(method=method, status_code=resp.status, content=raw_result)
  File "D:\Code\wqe\.venv\lib\site-packages\aiogram\client\session\base.py", line 84, in check_response
    response = method.build_response(json_data)
  File "D:\Code\wqe\.venv\lib\site-packages\aiogram\methods\base.py", line 82, in build_response
    return Response[self.__returning__](**data)  # type: ignore
  File "pydantic\main.py", line 342, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 26 validation errors for Response[List[aiogram.types.update.Update]]
result -> 0 -> my_chat_member -> new_chat_member -> status
  unexpected value; permitted: 'creator' (type=value_error.const; given=restricted; permitted=['creator'])
result -> 0 -> my_chat_member -> new_chat_member -> is_anonymous
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> status
  unexpected value; permitted: 'administrator' (type=value_error.const; given=restricted; permitted=['administrator'])
result -> 0 -> my_chat_member -> new_chat_member -> can_be_edited
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> is_anonymous
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_manage_chat
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_delete_messages
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_manage_voice_chats
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_restrict_members
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_promote_members
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_change_info
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_invite_users
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> status
  unexpected value; permitted: 'member' (type=value_error.const; given=restricted; permitted=['member'])
result -> 0 -> my_chat_member -> new_chat_member -> is_member
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_change_info
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_invite_users
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_pin_messages
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_send_messages
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_send_media_messages
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_send_polls
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_send_other_messages
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> can_add_web_page_previews
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> until_date
  field required (type=value_error.missing)
result -> 0 -> my_chat_member -> new_chat_member -> status
  unexpected value; permitted: 'left' (type=value_error.const; given=restricted; permitted=['left'])
result -> 0 -> my_chat_member -> new_chat_member -> status
  unexpected value; permitted: 'kicked' (type=value_error.const; given=restricted; permitted=['kicked'])
result -> 0 -> my_chat_member -> new_chat_member -> until_date
  field required (type=value_error.missing)

Process finished with exit code 1

Additional information

@evgfilim1 says the error in Telegram update ChatMemberRestricted and in my_chat_member there is only status=restricted field.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JrooTJuniorcommented, Oct 2, 2022

Yeah, i will close the issue after the Beta 5 released, and you are welcome to re-open the issue if you get such kind of errors after the upgrading

1reaction
Danipulokcommented, Sep 30, 2022

@evgfilim1 thanks. I added that, unfortunately, I don’t know what happened to TG to send updates like this one. So I can not provide steps to reproduce.

Read more comments on GitHub >

github_iconTop Results From Across the Web

telegram.error module - python-telegram-bot
This module contains an object that represents Telegram errors. ... Raised when Telegram could not process the request correctly. ... Raised when the...
Read more >
ErrorEvent - aiogram 3.0.0b7 documentation
Internal event, should be used to receive errors while processing Updates from Telegram. Source: https://core.telegram.org/bots/api#error-event.
Read more >
python-telegram-bot Documentation
telegram.error.TelegramError – property base_file_url. Telegram Bot API file URL, built from Bot.base_file_url and Bot.token. New in version 20.0.
Read more >
API Reference — ex_gram v0.30.0
Named process that receive the updates, apply the middlewares for the bot and call the ... Encoder.Engine module with the engine selected. ExGram.Error....
Read more >
Solved: How to deal with "There was an error processing yo...
Individual API calls are working fine, but when I try to string them together, I'm getting the error: {"code": 500, "message": "There was...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found