openclaw - ✅(Solved) Fix message send --media silently drops attachment for WhatsApp (gateway delivery mode) [1 pull requests, 1 comments, 2 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#64478Fetched 2026-04-11 06:14:43
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
referenced ×3closed ×1commented ×1cross-referenced ×1

openclaw message send --channel whatsapp --target JID --media /path/to/file.pdf --message "caption" sends only the caption text. The PDF attachment is silently ignored — no error, no warning.

Error Message

openclaw message send --channel whatsapp --target JID --media /path/to/file.pdf --message "caption" sends only the caption text. The PDF attachment is silently ignored — no error, no warning.

Root Cause

WhatsApp uses deliveryMode: "gateway". In message-CkKbBLhv.js, the gateway path calls callMessageGateway with mediaUrl in params, but the gateway-side handler only processes the message field and forwards text to Baileys.

The #54034 security fix in 2026.3.24 correctly blocked unauthorized media access via assertLocalMediaAllowed, and mediaLocalRoots was subsequently propagated through direct-mode channel adapters:

  • Slack (#36656)
  • Feishu (#27884)
  • Discord, iMessage, Signal
  • WhatsApp direct mode (#33581)

However, the WhatsApp gateway delivery path (callMessageGateway → gateway WebSocket → Baileys) was missed. The gateway-side send handler does not resolve mediaLocalRoots, does not call loadOutboundMediaFromUrl, and does not pass media buffers to Baileys.

Fix Action

Fixed

PR fix notes

PR #64492: fix(cli): route gateway media sends through sendMedia

Description (problem / solution / changelog)

Summary

  • route CLI/runtime sends with media through the channel outbound adapter's sendMedia path instead of always falling back to sendText
  • preserve outbound media access/mediaLocalRoots/mediaReadFile when delegating gateway-mode sends
  • add regression coverage for CLI runtime media routing and gateway send session context

Closes #64478

Testing

  • attempted: OPENCLAW_LOCAL_CHECK=0 pnpm test src/cli/send-runtime/channel-outbound-send.test.ts src/gateway/server-methods/send.test.ts
  • blocked locally in this worktree because node_modules / vitest are unavailable (Cannot find module 'vitest/package.json')
  • sending to CI for verification

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/cli/send-runtime/channel-outbound-send.test.ts (added, +132/-0)
  • src/cli/send-runtime/channel-outbound-send.ts (modified, +27/-0)
  • src/gateway/server-methods/send.test.ts (modified, +30/-0)

Code Example

openclaw message send --channel whatsapp \
  --target "[email protected]" \
  --media ~/.openclaw/media/test.pdf \
  --message "test caption" --json
RAW_BUFFERClick to expand / collapse

Description

openclaw message send --channel whatsapp --target JID --media /path/to/file.pdf --message "caption" sends only the caption text. The PDF attachment is silently ignored — no error, no warning.

Version info

  • Regression in: 2026.3.24 (likely #54034)
  • Last working: 2026.3.23-2
  • Current: 2026.4.9

Reproduction

openclaw message send --channel whatsapp \
  --target "[email protected]" \
  --media ~/.openclaw/media/test.pdf \
  --message "test caption" --json

Payload contains mediaUrl correctly. Gateway completes send in 3-5ms (no file upload occurs). Only text arrives. Tested with:

  • Local paths under ~/.openclaw/media/ (inside allowed roots)
  • HTTP localhost URLs
  • Google Drive download URLs

All silently ignored. --force-document has no effect.

Root cause analysis

WhatsApp uses deliveryMode: "gateway". In message-CkKbBLhv.js, the gateway path calls callMessageGateway with mediaUrl in params, but the gateway-side handler only processes the message field and forwards text to Baileys.

The #54034 security fix in 2026.3.24 correctly blocked unauthorized media access via assertLocalMediaAllowed, and mediaLocalRoots was subsequently propagated through direct-mode channel adapters:

  • Slack (#36656)
  • Feishu (#27884)
  • Discord, iMessage, Signal
  • WhatsApp direct mode (#33581)

However, the WhatsApp gateway delivery path (callMessageGateway → gateway WebSocket → Baileys) was missed. The gateway-side send handler does not resolve mediaLocalRoots, does not call loadOutboundMediaFromUrl, and does not pass media buffers to Baileys.

Related

  • #54131 — MEDIA: token in agent replies also fails silently for WhatsApp
  • #54034 — Security fix that introduced the regression
  • #33581 — WhatsApp mediaLocalRoots propagation (direct mode only)

Expected fix

Propagate mediaLocalRoots (or the fs policy / mediaAccess) through callMessageGateway so the gateway-side send handler can authorize and load the media file before passing it to Baileys, matching the behavior of direct-mode channels.

extent analysis

TL;DR

The most likely fix is to propagate mediaLocalRoots through the callMessageGateway function to enable the gateway-side send handler to authorize and load media files for WhatsApp.

Guidance

  • Review the message-CkKbBLhv.js file to understand how callMessageGateway is currently handling media URLs and identify where mediaLocalRoots needs to be propagated.
  • Update the gateway-side send handler to resolve mediaLocalRoots, call loadOutboundMediaFromUrl, and pass media buffers to Baileys, similar to how direct-mode channels are handled.
  • Verify that the mediaAccess policy or file system policy is correctly configured to allow access to the media files.
  • Test the changes with different types of media files and URLs to ensure that the issue is fully resolved.

Example

// Example of how callMessageGateway might be updated to propagate mediaLocalRoots
function callMessageGateway(params) {
  // ...
  const mediaLocalRoots = getMediaLocalRoots(); // Assuming this function returns the mediaLocalRoots
  params.mediaLocalRoots = mediaLocalRoots;
  // ...
  const mediaBuffer = loadOutboundMediaFromUrl(params.mediaUrl, mediaLocalRoots);
  // ...
  baileys.sendMessage(params.message, mediaBuffer);
}

Notes

The fix requires updating the callMessageGateway function and the gateway-side send handler to correctly handle media files for WhatsApp. This change should be tested thoroughly to ensure that it resolves the issue without introducing new problems.

Recommendation

Apply the workaround by propagating mediaLocalRoots through callMessageGateway and updating the gateway-side send handler, as this is the most direct way to resolve the issue.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix message send --media silently drops attachment for WhatsApp (gateway delivery mode) [1 pull requests, 1 comments, 2 participants]