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 into
Conversation
42ed0ad to
2b04836
Compare
2b04836 to
34548ee
Compare
34548ee to
c9d3c48
Compare
…ed mode dispatch
c9d3c48 to
3965bcb
Compare
3965bcb to
b8ef8e1
Compare
b8ef8e1 to
752639d
Compare
752639d to
b32a237
Compare
b32a237 to
1c4a9a2
Compare
220e7c0 to
63b520a
Compare
63b520a to
0d33f5e
Compare
0d33f5e to
05dc0e0
Compare
05dc0e0 to
7c51eb5
Compare
f29f458 to
d4775d1
Compare
d4775d1 to
9df5722
Compare
|
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