Skip to content

Discord inbound attachment download ignores channel proxy configuration #25232

@evan966890

Description

@evan966890

Bug Description

Discord inbound attachments (.txt, .md, images) fail to download silently when a proxy is configured for the Discord channel. The attachment file never appears in ~/.openclaw/media/inbound/, and the error is only logged via logVerbose() which is suppressed at normal log levels.

Root Cause Analysis

In processDiscordMessage()resolveMediaList()appendResolvedMediaFromAttachments(), the call to fetchRemoteMedia() does NOT pass through the configured proxy's fetchImpl:

// Discord (broken) - no fetchImpl/proxy
const fetched = await fetchRemoteMedia({
    url: attachment.url,
    filePathHint: attachment.filename ?? attachment.url,
    maxBytes: params.maxBytes
});

While fetchRemoteMedia() supports a fetchImpl parameter, and other channels (e.g., Telegram) correctly pass proxyFetch through their pipeline, the Discord implementation does not.

Node.js native fetch() (undici) does NOT honor HTTP_PROXY/HTTPS_PROXY environment variables and requires an explicit ProxyAgent dispatcher. This means Discord attachment downloads always use direct connections, bypassing the proxy configured in channels.discord.proxy.

Environment

  • OpenClaw version: 2026.2.23
  • Platform: macOS (Apple Silicon)
  • Proxy: v2rayN/xray on 127.0.0.1:10808 (configured in channels.discord.proxy)
  • DNS resolution: cdn.discordapp.com resolves to 108.160.165.53 (Fastly CDN, public IP)
  • Region: China (Discord CDN blocked without proxy)

Steps to Reproduce

  1. Configure Discord channel with a proxy: "proxy": "http://127.0.0.1:10808"
  2. Send a .txt file attachment to the bot via Discord DM
  3. Observe that the bot receives the text message but NOT the attachment content
  4. Check ~/.openclaw/media/inbound/ — no new file appears
  5. No error in standard logs (only visible with verbose logging enabled)

Expected Behavior

appendResolvedMediaFromAttachments() should use the same proxy configured in channels.discord.proxy when calling fetchRemoteMedia(), consistent with how Telegram handles media downloads.

Related Issues

Suggested Fix

Thread the Discord channel's proxy fetchImpl through the call chain:

// In resolveMediaList / appendResolvedMediaFromAttachments
const fetched = await fetchRemoteMedia({
    url: attachment.url,
    filePathHint: attachment.filename ?? attachment.url,
    maxBytes: params.maxBytes,
    fetchImpl: proxyFetch  // from Discord channel config
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions