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

TypeNotFoundError when handling incoming updates #1724

Closed
vegeta1k95 opened this issue Mar 12, 2021 · 7 comments
Closed

TypeNotFoundError when handling incoming updates #1724

vegeta1k95 opened this issue Mar 12, 2021 · 7 comments

Comments

@vegeta1k95
Copy link
Contributor

vegeta1k95 commented Mar 12, 2021

When running Telethon as bot, whenever I have some update arriving (i suppose this occurs for "chat action" events),
I am catching TypeNotFoundError.

Example: I run Telethon bot session, with chat action handler set up.
When I am adding / removing my bot to / from the channel, ithe following error occurs:

Unhandled error while processing msgs
Traceback (most recent call last):
  File "D:\!_Work\Python38\lib\site-packages\telethon\network\mtprotosender.py", line 540, in _recv_loop
    await self._process_message(message)
  File "D:\!_Work\Python38\lib\site-packages\telethon\network\mtprotosender.py", line 555, in _process_message
    await handler(message)
  File "D:\!_Work\Python38\lib\site-packages\telethon\network\mtprotosender.py", line 644, in _handle_gzip_packed
    message.obj = reader.tgread_object()
  File "D:\!_Work\Python38\lib\site-packages\telethon\extensions\binaryreader.py", line 142, in tgread_object
    return clazz.from_reader(self)
  File "D:\!_Work\Python38\lib\site-packages\telethon\tl\types\__init__.py", line 26902, in from_reader
    _x = reader.tgread_object()
  File "D:\!_Work\Python38\lib\site-packages\telethon\extensions\binaryreader.py", line 140, in tgread_object
    raise error
telethon.errors.common.TypeNotFoundError: Could not find a matching Constructor ID for the TLObject that was supposed to be read with ID 7fecb1ec. Most likely, a TLObject was trying to be read when it should not be read. Remaining bytes: b'\xec\xb1\xec\x7f\x03\x00\x00\x00\x8fOOW\xdf\xf6J`;\x14\xb0\x1b+\xed\xd4%\xaf\xac\x0f\x1c\x01\x00\x00\x00+\xed\xd4%;\x14\xb0\x1b^\xf6J`\x18\x04\x12\x9f\xff\x85\x02\x00\xff\xff\xff\x7f\xaf\xbb\xbe\xcc\x02\x00\x00\x00+\xed\xd4%;\x14\xb0\x1b;\x14\xb0\x1b\xdf\xf6J`\xd5$\xb2_?\x10\x00\x00\x8cdQ \x15\xc4\xb5\x1c\x02\x00\x00\x00\xc1X\x84\x93O\x00@\x02;\x14\xb0\x1bMW\xb1\x035\xc9\xae\xc2\x04Tarp\x00\x00\x00\nHammelherd\x00\x0etarphammelherd\x00\xf1Bo\xe2\x02ru\x00\xc1X\x84\x93\x0bD\x00\x02+\xed\xd4%\xef\xe3\xfe\xe2\rF\xb7\xfb\x07PushBot\x0bapppush_bot\x01\x00\x00\x00\x15\xc4\xb5\x1c\x01\x00\x00\x00\x1e\x96\x1a\xd3 `\x00\x00\x8fOOW\xc6p^\xe4$bs\x9c\x10Test Bot Channel\x00\x00\x00\x1c\x01\xc17\xdf\xf6J`\x00\x00\x00\x00\xd5$\xb2_?\x10\x00\x00\xde\xf6J`\x00\x00\x00\x00'

What is going on? Does the schema somehow messed up?

This occurs on the last Telethon 1.20.0 from PyPi.
Previous version I used (1.17.6) did not have this.

@Lonami
Copy link
Member

Lonami commented Mar 12, 2021

Does the schema somehow messed up?

https://t.me/LonamiWebs/14118, https://t.me/TelethonChat/311471.

telegram seems to be sending you an old message type for some reason

it should not do that

i really don't understand why the server sends types corresponding to other layers so damn often

it's stupid that the server cannot get the types right randomly

really makes no sense why telegram is sending types that do not exist

there is not much telethon can do, because telegram is sending an object telethon has no knowledge of, so it has no way of parsing it

@vegeta1k95
Copy link
Contributor Author

vegeta1k95 commented Mar 12, 2021

@Lonami
I experimented with different Telethon releases and found out the following:

Setting: MTProto Bot session (with bot_token set) and with handler for events.ChatAction().
My actions:
1) Start bot, add handler
2) Add this bot (as admin) to an empty channel,
3) Remove the bot from the channel.

Results:

  1. Telethon v. <= 1.18.2: ChatAction.Event received normally by handler, for both adding (user_joined=True) and removing (user_left=True);
  2. Telethon 1.19.0 <= v <= 1.19.5: ChatAction.Event's are not received at all, no errors;
  3. Telethon 1.20.0: TypeNotFoundError as above;

It seems there has been some changes of how does the Bot API handles updates?

Can you confirm this behavior for yourself?

@thegasta
Copy link

Same issue with 7fecb1ec

  • client.catch_up() was raising the error
  • deleting the session file "solved" and unlocked catch_up
  • but the error is still there and it's logged as a warning by client.run_until_disconnected()

(Telethon 1.20)

@Lonami
Copy link
Member

Lonami commented Mar 14, 2021

If you replace the api.tl file in this repository with https://github.com/telegramdesktop/tdesktop/blob/dev/Telegram/Resources/tl/api.tl and install, does the error go away?

@thegasta
Copy link

Yep, no error 👍

@Lonami Lonami closed this as completed in 8f46f70 Mar 14, 2021
kfur pushed a commit to kfur/Telethon that referenced this issue Oct 21, 2021
@Thoufak
Copy link

Thoufak commented Nov 10, 2021

@Lonami, this is still reproduced in the latest version. I've found the recommended solution in the docs:

image

This has also been confirmed by the TDLib's developer:

image

Does it make sense to you? Can this be fixed now?

@Lonami
Copy link
Member

Lonami commented Nov 10, 2021

This will need to be done when fixing the update handling.

@Lonami Lonami reopened this Nov 10, 2021
@Lonami Lonami closed this as completed in ed70991 Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants