Skip to content

fix(telegram): strip raw markdown in MarkdownV2 fallback paths - #34570

Closed
Vitalymt wants to merge 1 commit into
NousResearch:mainfrom
Vitalymt:fix/telegram-markdown-fallback-clean
Closed

fix(telegram): strip raw markdown in MarkdownV2 fallback paths#34570
Vitalymt wants to merge 1 commit into
NousResearch:mainfrom
Vitalymt:fix/telegram-markdown-fallback-clean

Conversation

@Vitalymt

Copy link
Copy Markdown

Problem

When Telegram rejects MarkdownV2 in edit_message (e.g. during streaming
finalization of multi-chunk responses), the fallback sends raw content
with literal bold markers and no parse_mode. Users see raw markdown
syntax instead of formatted or plain text.

Fix

  • _strip_mdv2(): strip raw bold (unconverted) before bold (converted)
  • edit_message fallback: use _strip_mdv2(content) + parse_mode=None
  • flood control retry: use already-formatted text or _strip_mdv2 fallback

Reproduced with long streamed responses split into chunks where the
second chunk (with inline buttons) triggered a MarkdownV2 parse error.

When Telegram rejects MarkdownV2 formatting in edit_message (e.g. during
streaming finalization), the fallback was sending raw content with literal
**bold** markers and no parse_mode. This caused users to see raw markdown
syntax instead of plain text.

Three fixes:
- _strip_mdv2(): add regex to strip raw **bold** before converted *bold*
- edit_message fallback: use _strip_mdv2(content) + parse_mode=None
- flood control retry: use already-formatted text or _strip_mdv2 fallback

Fixes the inconsistency where send() properly fell back to _strip_mdv2()
but edit_message() did not.
@Vitalymt Vitalymt closed this May 29, 2026
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter comp/gateway Gateway runner, session dispatch, delivery labels May 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #33304 — same title, same fix (strip raw **bold** in MarkdownV2 edit_message fallback paths). Please consolidate into #33304 which has the earlier review context.

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

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants