openclaw - ✅(Solved) Fix [Bug]: Telegram media download fails when proxy is socks5 [2 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#60472Fetched 2026-04-08 02:50:43
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2labeled ×2

When channels.telegram.proxy is set to socks5://127.0.0.1:1082, Telegram media file downloads fail with "Explicit proxy URL must use http or https". Regular bot API requests succeed.

Error Message

{"module":"telegram-auto-reply"} MediaFetchError: Failed to fetch media from https://api.telegram.org/file/bot.../photos/file_113.jpg: Explicit proxy URL must use http or https

Root Cause

When channels.telegram.proxy is set to socks5://127.0.0.1:1082, Telegram media file downloads fail with "Explicit proxy URL must use http or https". Regular bot API requests succeed.

Fix Action

Fix / Workaround

Workaround: switch proxy to http://127.0.0.1:<port>. Triggers a separate SSRF issue (filed separately).

PR fix notes

PR #60565: fix: Telegram media download fails when proxy is socks5

Description (problem / solution / changelog)

Summary

Telegram media downloads fail when using socks5:// proxy because the SSRF guard enforces pinned DNS checks that expect HTTP(S) proxy URLs. Since undici natively handles socks5:// proxies and the target media URL is always HTTPS, we disable the pinned DNS checks for media downloads by setting pinDns: false.

Changes

  • Added pinDns: false to fetchWithSsrFGuard call in src/media/fetch.ts for media downloads
  • This allows Telegram media to be downloaded through socks5:// proxies without SSRF pinned DNS validation errors

Testing

  • Ran vitest run src/media/fetch.test.ts - 7 tests passed
  • Ran vitest run extensions/telegram/src/fetch.test.ts - 22 tests passed

Fixes openclaw/openclaw#60472

Changed files

  • extensions/feishu/src/media.ts (modified, +3/-1)
  • extensions/ollama/index.ts (modified, +4/-1)
  • extensions/ollama/src/stream.ts (modified, +21/-2)

PR #63633: fix: support socks5/socks4 proxy via undici Socks5ProxyAgent

Description (problem / solution / changelog)

Fixes openclaw/openclaw#60472

makeProxyFetch() previously passed any proxy URL directly...

No new dependencies required.

Summary

  • Problem: makeProxyFetch() passes any proxy URL directly to undici's ProxyAgent, which only supports HTTP/HTTPS schemes. When channels.telegram.proxy is set to socks5:// or socks4://, undici throws on connection and all Telegram media downloads fail.
  • Why it matters: Users behind SOCKS5-only networks (e.g. Shadowsocks/Shadowrocket) cannot receive Telegram media at all; the failure is silent with no actionable error.
  • What changed: makeProxyFetch() now detects SOCKS schemes via isSocksProxyUrl() and dispatches to undici's built-in Socks5ProxyAgent instead of ProxyAgent. HTTP/HTTPS proxy paths are unchanged.
  • What did NOT change: SSRF guard logic, Telegram transport retry/fallback, env-proxy path, any other channel.

Change Type (select all)

  • Bug fix

Scope (select all touched areas)

  • Integrations

Linked Issue/PR

  • Closes #60472

Root Cause (if applicable)

  • Root cause: undici.ProxyAgent does not support SOCKS protocols; passing a socks5:// URI causes an immediate connection error.
  • Missing detection / guardrail: No scheme validation before constructing ProxyAgent.
  • Contributing context: undici 8.x ships Socks5ProxyAgent natively but it was never wired into makeProxyFetch().

Regression Test Plan (if applicable)

  • Coverage level:
    • Unit test
  • Target test: src/infra/net/proxy-fetch.test.ts
  • Scenario: makeProxyFetch("socks5://...") routes to Socks5ProxyAgent; makeProxyFetch("http://...") continues to use ProxyAgent; agent is reused across calls; getProxyUrlFromFetch() returns correct URL for SOCKS proxies.
  • Why smallest reliable guardrail: The fix is entirely within makeProxyFetch(); unit-level mock of undici constructors is sufficient.
  • Existing test that already covers this: None (SOCKS path was untested).

User-visible / Behavior Changes

Users can now set channels.telegram.proxy: "socks5://host:port" and Telegram media downloads will work correctly. Previously this silently failed.

Diagram (if applicable)

Before: makeProxyFetch("socks5://...") -> new ProxyAgent("socks5://...") -> undici error

After: makeProxyFetch("socks5://...") -> isSocksProxyUrl() == true -> new Socks5ProxyAgent({ uri }) -> OK makeProxyFetch("http://...") -> isSocksProxyUrl() == false -> new ProxyAgent(url) -> OK (unchanged)

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No (routing path changes, destination unchanged)
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: macOS 26 (arm64)
  • Runtime: Node.js v24.13.0
  • Integration/channel: Telegram
  • Relevant config: channels.telegram.proxy: "socks5://127.0.0.1:1080"

Steps

  1. Set channels.telegram.proxy to a socks5:// URL
  2. Send a photo/video via Telegram
  3. Agent attempts to download the media

Expected

Media downloads successfully through the SOCKS5 proxy.

Actual (before fix)

undici throws on connection; media download fails silently.

Evidence

  • Unit tests added: 5 new cases in proxy-fetch.test.ts

Human Verification (required)

  • Verified scenarios: socks5 proxy routing on macOS arm64 with Shadowrocket SOCKS5 (127.0.0.1:1080)
  • Edge cases checked: socks4://, agent reuse, proxyUrl metadata round-trip
  • What you did not verify: socks5h://, socks4a:// (added to isSocksProxyUrl() by spec but not tested against a live socks5h server)

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Risks and Mitigations

  • Risk: Socks5ProxyAgent constructor signature may differ between undici versions.
    • Mitigation: Checked against undici 8.0.2 (the pinned version); constructor accepts { uri: string }.

Changed files

  • extensions/telegram/src/fetch.ts (modified, +26/-4)
  • src/infra/net/proxy-fetch.test.ts (modified, +61/-1)
  • src/infra/net/proxy-fetch.ts (modified, +24/-6)

Code Example

{"module":"telegram-auto-reply"} MediaFetchError: Failed to fetch media from https://api.telegram.org/file/bot.../photos/file_113.jpg: Explicit proxy URL must use http or https
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When channels.telegram.proxy is set to socks5://127.0.0.1:1082, Telegram media file downloads fail with "Explicit proxy URL must use http or https". Regular bot API requests succeed.

Steps to reproduce

  1. Set channels.telegram.proxy: "socks5://127.0.0.1:1082" in openclaw.json
  2. Send an image to the bot via Telegram DM
  3. Observe gateway log: MediaFetchError: Explicit proxy URL must use http or https

Expected behavior

Image is downloaded and passed to the agent for processing, consistent with how bot API requests handle the same socks5 proxy.

Actual behavior

Media fetch fails. Agent receives no image. Gateway log shows MediaFetchError: Failed to fetch media from https://api.telegram.org/file/...: Explicit proxy URL must use http or https

OpenClaw version

2026.4.2

Operating system

macOS 26.4 arm64

Install method

npm global

Model

claude-sonnet-4-6

Provider / routing chain

openclaw → local acc proxy → anthropic

Additional provider/model setup details

No response

Logs, screenshots, and evidence

{"module":"telegram-auto-reply"} MediaFetchError: Failed to fetch media from https://api.telegram.org/file/bot.../photos/file_113.jpg: Explicit proxy URL must use http or https

Impact and severity

Affected: Any user with socks5 proxy configured for Telegram Severity: High (all media/images silently fail) Frequency: Always (100% reproducible) Consequence: Agent cannot process any image or file sent via Telegram

Additional information

Workaround: switch proxy to http://127.0.0.1:<port>. Triggers a separate SSRF issue (filed separately).

extent analysis

TL;DR

The issue can be worked around by using an HTTP proxy instead of a SOCKS5 proxy, but this may introduce a separate SSRF issue.

Guidance

  • The error message suggests that the media download functionality does not support SOCKS5 proxies, only HTTP or HTTPS proxies.
  • To verify this, try using an HTTP proxy (e.g., http://127.0.0.1:8080) instead of the SOCKS5 proxy and see if media downloads succeed.
  • Be aware that switching to an HTTP proxy may introduce a separate SSRF (Server-Side Request Forgery) issue, as mentioned in the additional information.
  • Consider filing a separate issue or feature request to support SOCKS5 proxies for media downloads.

Example

No code snippet is provided as the issue is related to configuration and proxy settings.

Notes

The provided workaround may not be suitable for all users due to the potential SSRF issue. A more permanent solution would be to add support for SOCKS5 proxies in the media download functionality.

Recommendation

Apply workaround: Use an HTTP proxy instead of a SOCKS5 proxy, while being aware of the potential SSRF issue, as it allows media downloads to work, albeit with a separate security concern.

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

Image is downloaded and passed to the agent for processing, consistent with how bot API requests handle the same socks5 proxy.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING