Skip to content

[Bug] get_chat_history raises 400 MESSAGE_IDS_EMPTY even when channel has message #150

@b1zya

Description

@b1zya

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install https://github.com/TelegramPlayground/pyrogram/archive/dev.zip --force-reinstall and reproduced the issue using the latest development version

Description

Description of the issue

For the past 2-3 days, get_chat_history has been returning [400 MESSAGE_IDS_EMPTY] for specific channels. Previously, it worked fine, and I was able to retrieve messages correctly.

This issue does not occur for all channels, only for certain ones. The problem started suddenly, which suggests that there might have been a change in the Telegram API, breaking Pyrogram’s behavior.

I have tried rolling back to older versions of Pyrogram, all the way down to 2.2.2, but the issue persists.

Important Observation

I attempted to retrieve messages using raw Telegram API with messages.GetHistory, and it successfully returns messages.
However, when using get_chat_history(), I receive [400 MESSAGE_IDS_EMPTY].

I would like to emphasize that I am not a professional programmer and I use neural networks to write code.

But if there is any information I can provide for debugging and a more accurate answer, let me know. I will try to do my best.

Steps to reproduce

Here's a raw API method that works correctly outputs all messages from the channel. Messages succeeded in getting. This means that it has nothing to do with the channel's privacy settings:

async def get_history_raw(app, channel_id, channel_name):
"""Fetches messages using raw Telegram API and saves each response as a separate txt file."""
peer = await app.resolve_peer(channel_id)
history = await app.invoke(GetHistory(
peer=peer,
offset_id=0,
limit=50,
add_offset=0,
max_id=0,
min_id=0,
hash=0,
offset_date=0
))
print(history) # The response contains messages

Code example

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions