Checklist
Description
Operating system
Windows 10
Debian GNU/Linux 12 (bookworm)
Python version
3.13.5
hydrogram version
0.2.0
When calling get_forum_topics on a forum chat that contains deleted topics, Hydrogram crashes with an AttributeError. It tries to parse ForumTopicDeleted objects as if they were ForumTopic, but those don’t have the same attributes.
what happens if you add logging to the topic parsing in the get_forum_topics function:
for _topic in r.topics:
try:
yield types.ForumTopic._parse(_topic)
except Exception as e:
print(f"error_parse: {_topic.__class__}")
logs:
error_parse: <class 'hydrogram.raw.types.forum_topic_deleted.ForumTopicDeleted'>
Steps to reproduce
- Create client as user
- Invoke get_forum_topics on a forum chat that contains deleted topics
Code example
import asyncio
from hydrogram import Client
from hydrogram.types import ForumTopic
API_ID =
API_HASH =
CHAT_ID = -1233 # forum chat with deleted topics
async def main():
async with Client("my_session", api_id=API_ID, api_hash=API_HASH) as app:
async for topic in app.get_forum_topics(CHAT_ID):
pass
asyncio.run(main())
Logs
Windows:
F:\projects\big_projects\test_hydro>f:/projects/big_projects/test_hydro/.venv/Scripts/python.exe f:/projects/big_projects/test_hydro/main.py
Traceback (most recent call last):
File "f:\projects\big_projects\test_hydro\main.py", line 49, in <module> asyncio.run(main())
~~~~~~~~~~~^^^^^^^^
File "C:\Program Files\Python313\Lib\asyncio\runners.py", line 195, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "C:\Program Files\Python313\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "C:\Program Files\Python313\Lib\asyncio\base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "f:\projects\big_projects\test_hydro\main.py", line 37, in main
async for topic in topics:
pass
File "f:\projects\big_projects\test_hydro\.venv\Lib\site-packages\hydrogram\methods\chats\get_forum_topics.py", line 71, in get_forum_topics
yield types.ForumTopic._parse(_topic)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "f:\projects\big_projects\test_hydro\.venv\Lib\site-packages\hydrogram\types\user_and_chats\forum_topic.py", line 127, in _parse
from_id = forum_topic.from_id
^^^^^^^^^^^^^^^^^^^
AttributeError: 'ForumTopicDeleted' object has no attribute 'from_id'
Linux:
Traceback (most recent call last):
File "/app/main.py", line 51, in <module>
asyncio.run(main())
~~~~~~~~~~~^^^^^^^^
File "/usr/local/lib/python3.13/asyncio/runners.py", line 195, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "/usr/local/lib/python3.13/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/usr/local/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/app/main.py", line 39, in main
async for topic in topics:
pass
File "/usr/local/lib/python3.13/site-packages/hydrogram/methods/chats/get_forum_topics.py", line 71, in get_forum_topics
yield types.ForumTopic._parse(_topic)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/hydrogram/types/user_and_chats/forum_topic.py", line 127, in _parse
from_id = forum_topic.from_id
^^^^^^^^^^^^^^^^^^^
AttributeError: 'ForumTopicDeleted' object has no attribute 'from_id'
Checklist
pip3 install -U https://github.com/hydrogram/hydrogram/archive/dev.zipand reproduced the issue using the latest development versionDescription
Operating system
Windows 10
Debian GNU/Linux 12 (bookworm)
Python version
3.13.5
hydrogram version
0.2.0
When calling get_forum_topics on a forum chat that contains deleted topics, Hydrogram crashes with an AttributeError. It tries to parse ForumTopicDeleted objects as if they were ForumTopic, but those don’t have the same attributes.
what happens if you add logging to the topic parsing in the get_forum_topics function:
logs:
error_parse: <class 'hydrogram.raw.types.forum_topic_deleted.ForumTopicDeleted'>
Steps to reproduce
Code example
Logs