#6566: fix: thread fileName through WhatsApp document send path
channel: whatsapp-web
Cluster:
WhatsApp Document Handling Fixes
When sending non-image/audio/video files via WhatsApp, the Baileys payload always used `fileName: "file"` regardless of the actual file name. The fileName from `loadWebMedia` (or an explicit option) was never passed through the send chain.
## Changes
- Add `fileName` to `ActiveWebSendOptions`
- Extract `media.fileName` in `sendMessageWhatsApp` and pass it via `sendOptions`
- Use `sendOptions.fileName` in `send-api` document payload (fallback: `"file"`)
- Add unit tests for send-api fileName handling
## Files changed
- `src/web/active-listener.ts` — add `fileName?: string` to options type
- `src/web/outbound.ts` — extract and pass `media.fileName`
- `src/web/inbound/send-api.ts` — use `sendOptions?.fileName` instead of hardcoded `"file"`
- `src/web/inbound/send-api.test.ts` — new tests
Fixes #6455
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR threads a `fileName` option through the WhatsApp Web send pipeline so document uploads use the correct filename. It extends `ActiveWebSendOptions`, propagates `media.fileName` (or an explicit override) from `sendMessageWhatsApp` into the send options, and updates `createWebSendApi` to set `fileName` on Baileys document payloads with a default fallback. Unit tests were added to validate filename behavior for document messages and to ensure non-document payloads don’t get a `fileName`.
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge; changes are small and covered by focused unit tests.
- The change is a straightforward data plumbing update with limited surface area (options type + payload construction) and adds tests that exercise the new behavior. Main remaining risk is subtle semantics around falsy `fileName` values and minor option-shape consistency.
- src/web/inbound/send-api.ts (filename fallback semantics), src/web/outbound.ts (sendOptions shape)
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#10889: fix: pass fileName through WhatsApp document send path
by DeveshParagiri · 2026-02-07
94.2%
#15650: fix(whatsapp): pass fileName to document sends instead of hardcodin...
by whoknowsmann · 2026-02-13
92.4%
#9606: fix: pass fileName to WhatsApp document messages
by AytuncYildizli · 2026-02-05
91.7%
#7458: fix: pass filename through to WhatsApp document sends (#7446)
by gavinbmoore · 2026-02-02
89.7%
#16785: fix(whatsapp): preserve document filenames in outbound Baileys mode
by SahilSahu731 · 2026-02-15
88.3%
#21881: fix(whatsapp): pass user-provided fileName through document send pipe…
by saakshigupta2002 · 2026-02-20
88.3%
#16817: fix(whatsapp): infer extension-aware fallback filename for Baileys ...
by VintLin · 2026-02-15
86.4%
#8705: feat(whatsapp): add viewOnce support for ephemeral media
by ndohuu · 2026-02-04
80.4%
#23579: feat(whatsapp): add sender attribution to inbound message logs
by svan058 · 2026-02-22
78.0%
#17326: fix(whatsapp): group composing indicator, echo prevention, and pres...
by globalcaos · 2026-02-15
75.9%