Skip to content

fix(telegram): gracefully handle deleted reply targets - #3231

Closed
heathley wants to merge 1 commit into
NousResearch:mainfrom
heathley:fix/telegram-reply-target-deleted-2
Closed

fix(telegram): gracefully handle deleted reply targets#3231
heathley wants to merge 1 commit into
NousResearch:mainfrom
heathley:fix/telegram-reply-target-deleted-2

Conversation

@heathley

Copy link
Copy Markdown
Contributor

Fixes #3229

Race condition: user deletes their message while Hermes processes → Telegram returns BadRequest: Message to be replied not found → previously uncaught, delivery silently failed.

Fix: catch TelegramBadRequest with that specific message in the send() retry loop, clear reply_to_id, retry without threading. Message is always delivered.

When a user deletes their message while Hermes is processing (race
condition), Telegram returns `BadRequest: Message to be replied not
found`. This was previously uncaught — causing silent delivery failure
instead of the message being delivered without threading.

Fix: catch TelegramBadRequest with that error text in the send() retry
loop, clear reply_to_id, and let the next attempt deliver the message
unthreaded. No message is lost.

Closes NousResearch#3229
@heathley
heathley force-pushed the fix/telegram-reply-target-deleted-2 branch from aedf071 to f31b925 Compare March 26, 2026 17:00
teknium1 pushed a commit that referenced this pull request Mar 30, 2026
When a user deletes their message while Hermes is processing, Telegram
returns BadRequest 'Message to be replied not found'. Previously this
was an unhandled permanent error causing silent delivery failure.

Now clears reply_to_id and retries so the response is still delivered,
matching the existing 'thread not found' recovery pattern.

Inspired by PR #3231 by @heathley. Fixes #3229.
teknium1 added a commit that referenced this pull request Mar 30, 2026
* fix: add gpt-5.4-mini to Codex fallback catalog

* fix(telegram): gracefully handle deleted reply targets

When a user deletes their message while Hermes is processing, Telegram
returns BadRequest 'Message to be replied not found'. Previously this
was an unhandled permanent error causing silent delivery failure.

Now clears reply_to_id and retries so the response is still delivered,
matching the existing 'thread not found' recovery pattern.

Inspired by PR #3231 by @heathley. Fixes #3229.

---------

Co-authored-by: Clippy <clippy@grads.flow>
Co-authored-by: Nigel Gibbs <heathley@users.noreply.github.com>
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #3858. Your fix was adapted to fit the current main's existing BadRequest handling pattern (isinstance check inside the _NetErr catch) rather than a separate except clause. Same behavior, consistent with the 'thread not found' recovery already there. Authorship preserved. Thanks @heathley!

@teknium1 teknium1 closed this Mar 30, 2026
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…3858)

* fix: add gpt-5.4-mini to Codex fallback catalog

* fix(telegram): gracefully handle deleted reply targets

When a user deletes their message while Hermes is processing, Telegram
returns BadRequest 'Message to be replied not found'. Previously this
was an unhandled permanent error causing silent delivery failure.

Now clears reply_to_id and retries so the response is still delivered,
matching the existing 'thread not found' recovery pattern.

Inspired by PR NousResearch#3231 by @heathley. Fixes NousResearch#3229.

---------

Co-authored-by: Clippy <clippy@grads.flow>
Co-authored-by: Nigel Gibbs <heathley@users.noreply.github.com>
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…3858)

* fix: add gpt-5.4-mini to Codex fallback catalog

* fix(telegram): gracefully handle deleted reply targets

When a user deletes their message while Hermes is processing, Telegram
returns BadRequest 'Message to be replied not found'. Previously this
was an unhandled permanent error causing silent delivery failure.

Now clears reply_to_id and retries so the response is still delivered,
matching the existing 'thread not found' recovery pattern.

Inspired by PR NousResearch#3231 by @heathley. Fixes NousResearch#3229.

---------

Co-authored-by: Clippy <clippy@grads.flow>
Co-authored-by: Nigel Gibbs <heathley@users.noreply.github.com>
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…3858)

* fix: add gpt-5.4-mini to Codex fallback catalog

* fix(telegram): gracefully handle deleted reply targets

When a user deletes their message while Hermes is processing, Telegram
returns BadRequest 'Message to be replied not found'. Previously this
was an unhandled permanent error causing silent delivery failure.

Now clears reply_to_id and retries so the response is still delivered,
matching the existing 'thread not found' recovery pattern.

Inspired by PR NousResearch#3231 by @heathley. Fixes NousResearch#3229.

---------

Co-authored-by: Clippy <clippy@grads.flow>
Co-authored-by: Nigel Gibbs <heathley@users.noreply.github.com>
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…3858)

* fix: add gpt-5.4-mini to Codex fallback catalog

* fix(telegram): gracefully handle deleted reply targets

When a user deletes their message while Hermes is processing, Telegram
returns BadRequest 'Message to be replied not found'. Previously this
was an unhandled permanent error causing silent delivery failure.

Now clears reply_to_id and retries so the response is still delivered,
matching the existing 'thread not found' recovery pattern.

Inspired by PR NousResearch#3231 by @heathley. Fixes NousResearch#3229.

---------

Co-authored-by: Clippy <clippy@grads.flow>
Co-authored-by: Nigel Gibbs <heathley@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

bug: telegram.error.BadRequest in venv/lib/python3.11/site-packages/telegram/request/_baserequest.py:_request_wrapper

2 participants