openclaw - ✅(Solved) Fix bug(whatsapp): HTML files silently dropped on outbound send — .html/.htm missing from MIME_BY_EXT + no fallback for unknown MIME [3 pull requests, 3 comments, 4 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#51561Fetched 2026-04-08 01:09:36
View on GitHub
Comments
3
Participants
4
Timeline
14
Reactions
0
Author
Timeline (top)
commented ×3cross-referenced ×3referenced ×3subscribed ×2

Error Message

HTML files sent via the message tool are silently dropped — recipient gets text without any attachment. No error is logged. When mediaType is falsy, the entire media buffer is discarded and only text is sent. No error, no warning.

Root Cause

Root Cause (two bugs)

Fix Action

Workaround

Patch all 6 query-expansion-*.js chunks and 6 outbound-*.js chunks in dist/.

PR fix notes

PR #51562: fix(whatsapp): add HTML/XML/CSS to MIME map + fallback for unknown media types

Description (problem / solution / changelog)

Summary

HTML files sent via the message tool are silently dropped — recipients get text without any attachment. No error is logged. This also affects .xml, .css, and .htm files.

Root Cause

1. Missing MIME entries (src/media/mime.ts)

EXT_BY_MIME maps MIME types to extensions, then is reversed into MIME_BY_EXT for detection. HTML and several other common web types were missing:

  • text/html.html
  • text/xml.xml
  • text/css.css
  • application/xml.xml

Since HTML has no magic bytes, file-type returns undefined, and the extension-based fallback also fails → detectMime() returns undefined.

2. Silent media drop (extensions/whatsapp/src/send.ts + send-api.ts)

When mediaType is undefined:

  • In send.ts: mediaType = media.contentType stays undefined, passed to sendMessage(to, text, mediaBuffer, undefined)
  • In send-api.ts: the guard if (mediaBuffer && mediaType) is false → falls through to payload = { text } → media silently dropped

Fix

  1. Add missing entries to EXT_BY_MIME + .htm alias in MIME_BY_EXT
  2. Add ?? "application/octet-stream" fallback in both send paths so unknown file types are sent as documents instead of silently dropped
  3. Added test coverage for HTML/XML/CSS detection

Why not use a MIME database package?

Considered mime-types or mime-db packages, but:

  • The current hand-maintained map is intentionally small (focuses on types OpenClaw actually handles)
  • Adding a full MIME database (~1000 entries) for 4 missing entries is overkill
  • The application/octet-stream fallback in the send path is the real safety net — it ensures any future missing type still gets delivered

Test plan

  • New tests: detectMime for .html, .htm, .xml, .css files
  • New tests: extensionForMime for text/html, text/xml, text/css
  • Verified locally: HTML files now arrive as WhatsApp document attachments
  • Verified: PDF, PNG, TXT still work correctly (no regression)

Fixes #51561

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • extensions/whatsapp/src/inbound/send-api.test.ts (modified, +20/-0)
  • extensions/whatsapp/src/inbound/send-api.ts (modified, +3/-0)
  • extensions/whatsapp/src/send.ts (modified, +1/-1)
  • src/media/mime.test.ts (modified, +26/-0)
  • src/media/mime.ts (modified, +6/-0)

PR #51592: fix(media): add HTML, XML, CSS MIME entries to detection map

Description (problem / solution / changelog)

Summary

Add missing MIME type entries (text/html, text/xml, text/css, application/xml) to EXT_BY_MIME and .htm alias to MIME_BY_EXT in src/media/mime.ts.

Problem

HTML files sent via WhatsApp (and potentially other channels) are silently dropped because detectMime() returns undefined for .html files. The file-type package cannot detect HTML via magic bytes, so the fallback to MIME_BY_EXT is the only detection path — but .html was missing from the map.

This also affects .xml, .css, and .htm files.

Fix

  • Add text/html, text/xml, text/css, and application/xml to EXT_BY_MIME
  • Add .htm as an alias in MIME_BY_EXT

All 44 existing MIME tests pass.

Fixes #51561

Changed files

  • src/media/mime.ts (modified, +5/-0)

PR #52006: WhatsApp: fix HTML attachment MIME and outbound send (#51561)

Description (problem / solution / changelog)

Summary

Register text/html (plus .htm) in shared MIME maps, and infer text/html in WhatsApp outbound when loadWebMedia returns a document buffer without contentType but the filename is .html / .htm.

Test plan

  • pnpm test -- src/media/mime.test.ts extensions/whatsapp/src/send.test.ts

Fixes #51561

Made with Cursor

Changed files

  • extensions/whatsapp/src/send.test.ts (modified, +16/-0)
  • extensions/whatsapp/src/send.ts (modified, +7/-0)
  • src/media/mime.test.ts (modified, +13/-0)
  • src/media/mime.ts (modified, +17/-1)

Code Example

mediaType = media.contentType;  // undefined for HTML
// ...
// In createWebSendApi.sendMessage:
if (mediaBuffer && mediaType) {
    // build document payload
} else payload = { text };  // ← media silently dropped!

---

"text/html": ".html",
"text/xml": ".xml",
"text/css": ".css",
"application/xml": ".xml",

---

- mediaType = media.contentType;
+ mediaType = media.contentType ?? "application/octet-stream";
RAW_BUFFERClick to expand / collapse

Bug

HTML files sent via the message tool are silently dropped — recipient gets text without any attachment. No error is logged.

Root Cause (two bugs)

1. .html / .htm missing from EXT_BY_MIME map

src/media/mime.ts defines EXT_BY_MIME which maps MIME types to extensions. This map is reversed to create MIME_BY_EXT for extension-based MIME detection.

HTML has no magic bytes, so file-type (sniffMime) returns undefined. The fallback is MIME_BY_EXT[ext], but .html and .htm are not in the map.

Result: detectMime() returns undefined for .html files.

Other missing extensions: .xml, .css, .htm

2. sendMessageWhatsApp silently drops media when mediaType is undefined

In src/whatsapp/outbound.ts, sendMessageWhatsApp:

mediaType = media.contentType;  // undefined for HTML
// ...
// In createWebSendApi.sendMessage:
if (mediaBuffer && mediaType) {
    // build document payload
} else payload = { text };  // ← media silently dropped!

When mediaType is falsy, the entire media buffer is discarded and only text is sent. No error, no warning.

3. Bundler duplication amplifies both bugs

Both EXT_BY_MIME and sendMessageWhatsApp are duplicated across 6 output chunks by Rolldown code-splitting. All copies must be patched.

Fix

Minimal fix (src/media/mime.ts)

Add missing entries to EXT_BY_MIME:

"text/html": ".html",
"text/xml": ".xml",
"text/css": ".css",
"application/xml": ".xml",

Safety net (src/whatsapp/outbound.ts)

Add MIME fallback so unknown file types are sent as documents instead of silently dropped:

- mediaType = media.contentType;
+ mediaType = media.contentType ?? "application/octet-stream";

Better long-term fix

Consider using a comprehensive MIME database (e.g. mime-types package) instead of a hand-maintained map. The current map has 33 entries and will keep missing edge cases.

Also consider logging a warning when mediaType is undefined instead of silently falling through.

Environment

  • OpenClaw 2026.3.13
  • Tested with .html, .htm, .xml files — all silently dropped
  • .pdf, .png, .txt work fine (have magic bytes or are in the map)

Workaround

Patch all 6 query-expansion-*.js chunks and 6 outbound-*.js chunks in dist/.

extent analysis

Fix Plan

To fix the issue of HTML files being silently dropped when sent via the message tool, follow these steps:

  • Update EXT_BY_MIME map:
    • In src/media/mime.ts, add the following entries to the EXT_BY_MIME map:
      "text/html": ".html",
      "text/xml": ".xml",
      "text/css": ".css",
      "application/xml": ".xml",
  • Add MIME fallback:
    • In src/whatsapp/outbound.ts, update the mediaType assignment to include a fallback:
      mediaType = media.contentType ?? "application/octet-stream";
  • Patch duplicated code:
    • Update all 6 query-expansion-*.js chunks and 6 outbound-*.js chunks in dist/ with the above changes.

Verification

To verify that the fix worked:

  • Send an HTML file via the message tool and check that it is received as an attachment.
  • Test with different file types (e.g. .html, .htm, .xml, .pdf, .png, .txt) to ensure that all are sent correctly.

Extra Tips

  • Consider using a comprehensive MIME database (e.g. mime-types package) instead of a hand-maintained map to avoid missing edge cases.
  • Log a warning when mediaType is undefined instead of silently falling through to improve error handling.

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 bug(whatsapp): HTML files silently dropped on outbound send — .html/.htm missing from MIME_BY_EXT + no fallback for unknown MIME [3 pull requests, 3 comments, 4 participants]