Skip to content

fix(telegram): skip empty text replies instead of crashing with GrammyError 400#56620

Merged
hydro13 merged 1 commit intoopenclaw:mainfrom
hydro13:fix/telegram-empty-reply-crash
Mar 28, 2026
Merged

fix(telegram): skip empty text replies instead of crashing with GrammyError 400#56620
hydro13 merged 1 commit intoopenclaw:mainfrom
hydro13:fix/telegram-empty-reply-crash

Conversation

@hydro13
Copy link
Copy Markdown
Member

@hydro13 hydro13 commented Mar 28, 2026

Summary

  • Filter whitespace-only text chunks at bot delivery fan-in before they reach sendTelegramText()
  • Covers all three text delivery paths: normal replies, follow-up text, voice fallback text
  • Media-only replies unaffected
  • message_sent hook still fires with success: false for suppressed empty replies

Root Cause

deliverReplies() in extensions/telegram/src/bot/delivery.replies.ts checked !reply?.text (falsy) but not semantic emptiness. Whitespace-only or hook-blanked replies passed the check and reached sendTelegramText()bot.api.sendMessage() → GrammyError 400: message text is empty.

The direct outbound path (send.ts) and draft preview path already had empty guards. Only bot delivery was missing them.

Change Type

  • Bug fix

Testing

1104 tests pass across 76 Telegram test files. Updated regression tests:

  • Hook-blanked text reply → skipped, success: false
  • Whitespace-only text reply → skipped, no Telegram API call

Fixes #37278

…yError 400

Filter whitespace-only text chunks at the bot delivery fan-in before
they reach sendTelegramText(). Covers normal text replies, follow-up
text, and voice fallback text paths.

Media-only replies are unaffected. message_sent hook still fires with
success: false for suppressed empty replies.

Fixes openclaw#37278
@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: XS maintainer Maintainer-authored PR labels Mar 28, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 28, 2026

Greptile Summary

This PR fixes a GrammyError 400 crash caused by whitespace-only text payloads reaching bot.api.sendMessage() in the Telegram bot delivery path. A new filterEmptyTelegramTextChunks() helper is applied to all three text delivery paths (deliverTextReply, sendPendingFollowUpText, sendTelegramVoiceFallbackText) so that whitespace-only chunks are silently dropped before any Telegram API call is made, with the message_sent hook still firing with success: false.

Confidence Score: 5/5

Safe to merge — the fix is minimal, correctly targets all three text delivery paths, and is covered by regression tests.

No P0 or P1 issues found. The helper function is well-typed and applied consistently. Empty-chunk handling in sendChunkedTelegramReplyText is already correct (the for-loop simply doesn't execute). Tests cover both the hook-blanking and the whitespace-only input scenarios.

No files require special attention.

Important Files Changed

Filename Overview
extensions/telegram/src/bot/delivery.replies.ts Adds filterEmptyTelegramTextChunks() and applies it to all three text delivery paths; implementation is correct and consistent.
extensions/telegram/src/bot/delivery.test.ts Updates hook-blanking test to use whitespace content and converts previously-throwing empty-text test to a resolves assertion, accurately covering the new behavior.

Reviews (1): Last reviewed commit: "fix(telegram): skip empty text replies i..." | Re-trigger Greptile

@hydro13 hydro13 merged commit 4d6c8ed into openclaw:main Mar 28, 2026
36 of 38 checks passed
hydro13 added a commit that referenced this pull request Mar 28, 2026
alexcode-cc pushed a commit to alexcode-cc/clawdbot that referenced this pull request Mar 30, 2026
…yError 400 (openclaw#56620)

Filter whitespace-only text chunks at the bot delivery fan-in before
they reach sendTelegramText(). Covers normal text replies, follow-up
text, and voice fallback text paths.

Media-only replies are unaffected. message_sent hook still fires with
success: false for suppressed empty replies.

Fixes openclaw#37278
alexjiang1 pushed a commit to alexjiang1/openclaw that referenced this pull request Mar 31, 2026
…yError 400 (openclaw#56620)

Filter whitespace-only text chunks at the bot delivery fan-in before
they reach sendTelegramText(). Covers normal text replies, follow-up
text, and voice fallback text paths.

Media-only replies are unaffected. message_sent hook still fires with
success: false for suppressed empty replies.

Fixes openclaw#37278
pgondhi987 pushed a commit to pgondhi987/openclaw that referenced this pull request Mar 31, 2026
…yError 400 (openclaw#56620)

Filter whitespace-only text chunks at the bot delivery fan-in before
they reach sendTelegramText(). Covers normal text replies, follow-up
text, and voice fallback text paths.

Media-only replies are unaffected. message_sent hook still fires with
success: false for suppressed empty replies.

Fixes openclaw#37278
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…yError 400 (openclaw#56620)

Filter whitespace-only text chunks at the bot delivery fan-in before
they reach sendTelegramText(). Covers normal text replies, follow-up
text, and voice fallback text paths.

Media-only replies are unaffected. message_sent hook still fires with
success: false for suppressed empty replies.

Fixes openclaw#37278
Tardisyuan pushed a commit to Tardisyuan/openclaw that referenced this pull request Apr 30, 2026
…yError 400 (openclaw#56620)

Filter whitespace-only text chunks at the bot delivery fan-in before
they reach sendTelegramText(). Covers normal text replies, follow-up
text, and voice fallback text paths.

Media-only replies are unaffected. message_sent hook still fires with
success: false for suppressed empty replies.

Fixes openclaw#37278
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…yError 400 (openclaw#56620)

Filter whitespace-only text chunks at the bot delivery fan-in before
they reach sendTelegramText(). Covers normal text replies, follow-up
text, and voice fallback text paths.

Media-only replies are unaffected. message_sent hook still fires with
success: false for suppressed empty replies.

Fixes openclaw#37278
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…yError 400 (openclaw#56620)

Filter whitespace-only text chunks at the bot delivery fan-in before
they reach sendTelegramText(). Covers normal text replies, follow-up
text, and voice fallback text paths.

Media-only replies are unaffected. message_sent hook still fires with
success: false for suppressed empty replies.

Fixes openclaw#37278
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram channel crashes when agent emits empty reply (GrammyError 400: text must be non-empty)

1 participant