Skip to content

bug(telegram): fenced replies become attachment references without uploading a file #3746

Closed

Description

@alex-furman

Reproduction

Reproduced on unmodified official dev at 77d98132b55594cd47dcb31334104581ac54f0fa, Python 3.12, using the real shared router and Telegram adapter with httpx.MockTransport at the Telegram HTTP boundary (no live bot).

  1. Return a fenced txt response containing "long reply\n" * 600 through ChannelMessageRouter._finalize_response with a TelegramAdapter.
  2. Record Telegram API calls.
  3. The only outgoing message is (see attached: response_1.txt). There is no sendDocument call, and none of the 6,000 characters of reply content reaches the recipient.

Expected: the complete response in ordered Telegram messages, keeping code formatting where possible, or a successfully uploaded attachment before any reference to it.

Cause

The shared router unconditionally calls _extract_outbound_files, which replaces recognized fenced blocks of at least 100 characters with attachment references. TelegramAdapter.send_response only reads response.text and ignores response.files. This affects blocks much shorter than Telegram's message-length limit too.

Related long-reply checks also expose HTML entities being split across chunks, astral Unicode not being counted conservatively, and later chunks being sent after an earlier chunk failed. Existing Markdown work #2277/#2295 closes/reopens tags but does not prevent entity cuts or the router's file substitution.

Acceptance

  • Telegram replies remain inline and split into ordered, bounded messages with practical code formatting.
  • Explicit file payloads are confirmed uploaded before their references are sent, with content-preserving split-text fallback on failure.
  • Retries target the current chunk; confirmed chunks are not replayed, and later chunks are not sent after an unconfirmed failure.
  • Regression coverage includes lengths around the limit, Markdown/code, Unicode, upload failure, duplicate filenames, ordering, and retries.

Activity

  1. added
    status-in-progress
    priority-p2
    type-bug
    theme-channels
    complexity-medium
    on Oct 17, 2026
  2. added
    status-in-dev
    and removed
    status-in-progress
    on Oct 19, 2026
  3. removed
    status-in-dev
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumpriority-p2theme-channelstype-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions