-
-
Notifications
You must be signed in to change notification settings - Fork 53k
Description
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:
processDiscordMessage→resolveMediaList(message, mediaMaxBytes)— no proxy paramresolveMediaList→appendResolvedMediaFromAttachments({...})— no fetchImplappendResolvedMediaFromAttachments→fetchRemoteMedia({url, filePathHint})— no fetchImplfetchRemoteMediafalls back toglobalThis.fetchwhich 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 resolveMediaList → appendResolvedMediaFromAttachments → fetchRemoteMedia({ 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 resolveMediaList → appendResolvedMediaFromAttachments → fetchRemoteMedia.
Steps to Reproduce
- Configure Discord channel with
channels.discord.proxy(required for servers in regions where Discord CDN is blocked) - User sends an image in DM
- Agent receives the message but image is not inline — only
<media:image> (1 image)placeholder - No files appear in
media/inbound/directory - 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.