Skip to content

Discord: inbound image attachments not delivered to agent when proxy is configured #22575

@Yuking1322

Description

@Yuking1322

Description

Discord image attachments sent in DMs are not delivered to the agent as inline media. The same setup works correctly on Telegram.

Environment

  • OpenClaw: 2026.2.19-2
  • Node.js: v22.22.0
  • Server: Ubuntu (China mainland, behind HTTP proxy)
  • Discord proxy configured: channels.discord.proxy
  • Primary model supports image input

Root Cause (source analysis)

In reply-B4B0jUCM.js, the Discord appendResolvedMediaFromAttachments function calls fetchRemoteMedia without passing the proxy fetchImpl:

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

Meanwhile, fetchRemoteMedia supports a fetchImpl parameter, and Telegram correctly passes proxyFetch through its pipeline.

The call chain is:

  1. processDiscordMessageresolveMediaList(message, mediaMaxBytes) — no proxy param
  2. resolveMediaListappendResolvedMediaFromAttachments({...}) — no fetchImpl
  3. appendResolvedMediaFromAttachmentsfetchRemoteMedia({url, filePathHint}) — no fetchImpl
  4. fetchRemoteMedia falls back to globalThis.fetch which does not use proxy

Node.js native fetch (undici) does not honor HTTP_PROXY/HTTPS_PROXY env vars — it requires an explicit ProxyAgent dispatcher.

Suggested Fix

Pass channels.discord.proxy through makeProxyFetch() to resolveMediaListappendResolvedMediaFromAttachmentsfetchRemoteMedia({ fetchImpl }), similar to how Telegram does it.

// In processDiscordMessage:
const discordProxyFetch = discordConfig?.proxy ? makeProxyFetch(discordConfig.proxy) : void 0;
const mediaList = await resolveMediaList(message, mediaMaxBytes, discordProxyFetch);
const forwardedMediaList = await resolveForwardedMediaList(message, mediaMaxBytes, discordProxyFetch);

And thread fetchImpl through resolveMediaListappendResolvedMediaFromAttachmentsfetchRemoteMedia.

Steps to Reproduce

  1. Configure Discord channel with channels.discord.proxy (required for servers in regions where Discord CDN is blocked)
  2. User sends an image in DM
  3. Agent receives the message but image is not inline — only <media:image> (1 image) placeholder
  4. No files appear in media/inbound/ directory
  5. Logs show Failed to fetch media from https://cdn.discordapp.com/... (before env var workaround) or silent failure

Workaround

Manually patching the dist file to thread fetchImpl through the call chain resolves the issue. Setting HTTPS_PROXY env var alone does NOT work because Node.js undici ignores it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions