fix(telegram): preserve reply text in threaded mode dispatch#17769
fix(telegram): preserve reply text in threaded mode dispatch#17769Glucksberg wants to merge 1 commit intoopenclaw:mainfrom
Conversation
|
Closing as AI-assisted stale-fix triage. Linked issue #7186 ("Telegram threaded replies fail with empty message text") is currently CLOSED and was closed on 2026-02-24T04:28:56Z with state reason NOT_PLANNED. If the underlying bug is still reproducible on current main, please reopen this PR (or open a new focused fix PR) and reference both #7186 and #17769 for fast re-triage. |
|
Closed after AI-assisted stale-fix triage (closed issue duplicate/stale fix). |
|
Follow-up: this bug now has two active implementation paths:
#25096 was opened as a narrow/small-diff alternative for faster merge if maintainers prefer minimal scope. Once one path is chosen for merge, the other can be closed by either me or the maintainer to keep queue hygiene clean. Fresh repro evidence is documented in #25091. |
Fixes #7186
Problem
In Telegram threaded mode, certain markdown-only inputs (e.g.
>) render to empty HTML viamarkdownToTelegramHtml(). The empty string is then passed tobot.api.sendMessage(), which rejects it with a 400 error: "message text is empty". The reply is silently lost.Fix
Instead of silently dropping messages when HTML is empty, this fix falls back to sending the original plain text:
sendPlainFallback()helper (DRYs up the duplicatedsendMessagecall)markdownToTelegramHtml()produces empty output, callssendPlainFallback()instead of skippingEMPTY_TEXT_ERR_REto also catch edge cases where empty text slips past the static check at runtimeundefinedgracefullyChanges
src/telegram/bot/delivery.ts— RefactoredsendTelegramText()with early empty-HTML fallback, sharedsendPlainFallback()helper, andEMPTY_TEXT_ERR_REerror catchsrc/telegram/bot/delivery.test.ts— Added test: "falls back to plain text when markdown renders to empty HTML in threaded mode"Tests
All existing delivery tests pass.
Greptile Summary
This PR fixes a bug where Telegram threaded mode silently drops replies when markdown-only inputs (e.g.,
>) render to empty HTML viamarkdownToTelegramHtml(). The empty string caused Telegram'ssendMessageAPI to reject with a 400 "message text is empty" error.!htmlText.trim()check insendTelegramText()to fall back to plain text before attempting the HTML send, avoiding the 400 error entirely.sendPlainFallback()helper, eliminating the duplicatedsendMessagecall that existed in the parse-error catch block.EMPTY_TEXT_ERR_REto catch "message text is empty" errors at runtime in case the static check is bypassed.sendPlainFallback()returnsundefinedinstead of throwing.>input in threaded (forum) mode.Confidence Score: 5/5
Last reviewed commit: 34548ee