openclaw - ✅(Solved) Fix [Bug]: Telegram inbound media download fails with MediaFetchError: TypeError: fetch failed [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#44624Fetched 2026-04-08 00:44:25
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×2closed ×1cross-referenced ×1locked ×1
  • OpenClaw 2026.3.11
  • macOS arm64
  • Telegram direct chat
  • Gateway running locally

Root Cause

  • OpenClaw 2026.3.11
  • macOS arm64
  • Telegram direct chat
  • Gateway running locally

Fix Action

Fixed

PR fix notes

PR #44639: fix(telegram): thread media transport policy into SSRF

Description (problem / solution / changelog)

Summary

  • thread an explicit Telegram transport object into media downloads instead of hiding transport hints on the fetch function
  • let SSRF-pinned media fetches compose from that transport policy so direct, env-proxy, and explicit-proxy routes stay aligned with normal Telegram API calls
  • add focused regressions for direct and explicit-proxy Telegram media downloads plus pinned dispatcher composition

Validation

  • pnpm vitest run src/media/fetch.telegram-network.test.ts src/infra/net/ssrf.dispatcher.test.ts src/telegram/fetch.test.ts src/telegram/bot/delivery.resolve-media-retry.test.ts
  • pnpm tsgo
  • pnpm check

Fixes #44624

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/infra/net/fetch-guard.ts (modified, +3/-1)
  • src/infra/net/ssrf.dispatcher.test.ts (modified, +92/-1)
  • src/infra/net/ssrf.ts (modified, +48/-6)
  • src/media/fetch.telegram-network.test.ts (added, +142/-0)
  • src/media/fetch.ts (modified, +4/-1)
  • src/telegram/bot-handlers.ts (modified, +4/-4)
  • src/telegram/bot-native-commands.ts (modified, +2/-1)
  • src/telegram/bot.ts (modified, +9/-7)
  • src/telegram/bot/delivery.resolve-media-retry.test.ts (modified, +11/-5)
  • src/telegram/bot/delivery.resolve-media.ts (modified, +24/-16)
  • src/telegram/fetch.test.ts (modified, +8/-2)
  • src/telegram/fetch.ts (modified, +121/-41)
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Summary

  • OpenClaw 2026.3.11
  • macOS arm64
  • Telegram direct chat
  • Gateway running locally

Steps to reproduce

Telegram inbound media should be downloaded and available to the agent.

Expected behavior

OpenClaw replies with ⚠️ Failed to download media. Please try again. and logs show MediaFetchError ... TypeError: fetch failed.

Actual behavior

OpenClaw replies with ⚠️ Failed to download media. Please try again. and logs show MediaFetchError: Failed to fetch media from https://api.telegram.org/file/...: TypeError: fetch failed.

OpenClaw version

2026.3.11

Operating system

macOS arm64

Install method

global install on macOS with Homebrew node

Model

openai-codex/gpt-5.4

Provider / routing chain

openclaw -> openai

Config file / key location

~/.openclaw/openclaw.json

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

Affected: Telegram users sending inbound media in direct chat Severity: High (blocks all Telegram image/file uploads to the agent) Frequency: 100% repro in this environment Consequence: Agent cannot access inbound Telegram media at all

Additional information

No response

extent analysis

Fix Plan

The fix involves updating the fetch function to handle errors properly and adding a retry mechanism.

Step-by-Step Solution

  1. Update the fetch function: Modify the fetch function to catch and handle errors.
  2. Add retry mechanism: Implement a retry mechanism to handle temporary network issues.
  3. Update OpenClaw configuration: Update the OpenClaw configuration to use the new fetch function.

Example Code

// Update the fetch function to handle errors
const fetchWithRetry = async (url, options, retries = 3) => {
  try {
    const response = await fetch(url, options);
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }
    return response;
  } catch (error) {
    if (retries > 0) {
      await new Promise(resolve => setTimeout(resolve, 1000)); // wait 1 second
      return fetchWithRetry(url, options, retries - 1);
    } else {
      throw error;
    }
  }
};

// Update OpenClaw to use the new fetch function
const openclawConfig = {
  // ...
  fetchFunction: fetchWithRetry,
  // ...
};

Verification

To verify the fix, send a media file via Telegram direct chat and check if the agent can access the media. The agent should no longer reply with ⚠️ Failed to download media. Please try again. and the logs should not show MediaFetchError.

Extra Tips

  • Make sure to update the OpenClaw configuration file (~/.openclaw/openclaw.json) with the new fetch function.
  • If the issue persists, check the network connectivity and the Telegram API status.
  • Consider adding more robust error handling and logging to the fetch function.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

OpenClaw replies with ⚠️ Failed to download media. Please try again. and logs show MediaFetchError ... TypeError: fetch failed.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING