Skip to content

Telegram: 'Failed to download media' when attaching files in group topics #32326

@a692570

Description

@a692570

Description

Attaching a .md file (document) in a Telegram group topic intermittently triggers:

⚠️ Failed to download media. Please try again.

The bot replies with this error instead of processing the file.

Environment

  • OpenClaw version: 2026.3.1
  • Channel: Telegram
  • Chat type: Group with topics (forum mode)
  • File type: .md (small text file, well under 20MB bot API limit)

Expected Behavior

The file should be downloaded and processed. If it fails transiently, the retry logic (currently 3 attempts) should handle it.

Actual Behavior

The resolveMedia flow calls ctx.getFile() → downloads from https://api.telegram.org/file/bot<token>/<path> but fails, triggering the generic error message.

Analysis

Looking at the source (reply-XaR8IPbY.js):

  • hasInboundMedia correctly detects msg.document
  • resolveInboundMediaFileId extracts document.file_id
  • retryAsync with 3 attempts, 1-4s delay with jitter
  • On failure, logs "media fetch failed" at warn level but the specific error is not included in the user-facing message

Possible Causes

  1. Race condition in group topics: Telegram may not make the file available via Bot API immediately in forum/topic messages
  2. Insufficient retry window: 3 retries × 1-4s may not be enough for topic messages
  3. Telegram API flakiness: getFile may return without file_path intermittently

Suggestions

  1. Include the actual error in the user-facing message (or at least in logs) for debuggability
  2. Consider increasing retry count or delay for group/topic contexts
  3. Add a longer initial delay before first getFile attempt for topic messages
  4. Persist the error details in gateway logs for post-mortem analysis

Reproduction

Intermittent. Send a .md file as a document in a Telegram group with topics enabled. More likely to occur than in DMs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions