#15650: fix(whatsapp): pass fileName to document sends instead of hardcoding 'file'
channel: whatsapp-web
stale
size: XS
Cluster:
WhatsApp Document Handling Fixes
#### Summary
Fix WhatsApp outbound documents always showing as "file" — the fileName from `loadWebMedia()` is now passed through to the Baileys `sendMessage` handler.
Fixes #15560
#### Behavior Changes
- Documents sent via WhatsApp now display their actual filename (e.g., `report.pdf`) instead of generic `file`
- No breaking changes — falls back to `"file"` if fileName is undefined
#### Codebase and GitHub Search
- Searched for existing fileName handling: found `loadWebMedia()` already returns `fileName` but it was not passed through
- Verified no other code paths affected
#### Tests
- Updated `src/web/outbound.test.ts` to expect the new sendOptions with fileName
- `pnpm test -- --run src/web/outbound.test.ts` passes (9/9)
- `pnpm build` passes
#### Manual Testing (omit if N/A)
Not tested on live WhatsApp — requires paired device. Fix is straightforward pass-through.
lobster-biscuit
**Sign-Off**
- Models used: Claude Opus 4.5
- Submitter effort (self-reported): AI-assisted, human-reviewed
- Agent notes: Code change is minimal (3 files, ~10 lines). The fix adds `fileName?: string` to `ActiveWebSendOptions`, captures `media.fileName` in `outbound.ts`, and uses `sendOptions?.fileName || "file"` in `send-api.ts`.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR threads the `fileName` returned by `loadWebMedia()` through WhatsApp outbound sending so Baileys document messages use the real filename instead of a hardcoded `"file"`. Concretely, it adds `fileName?: string` to `ActiveWebSendOptions`, captures `media.fileName` in `src/web/outbound.ts`, and uses `sendOptions?.fileName || "file"` when constructing the Baileys document payload in `src/web/inbound/send-api.ts`. Tests were updated to assert the new send options object.
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge after addressing one small behavioral consistency issue in outbound sendOptions construction.
- Changes are narrowly scoped and covered by a unit test, but `sendOptions` now sometimes includes `accountId: undefined` when the options object exists solely to pass `fileName`, which can be behaviorally different from omitting the field if downstream logic checks for property presence rather than value.
- src/web/outbound.ts
<sub>Last reviewed commit: 7740fbd</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#6566: fix: thread fileName through WhatsApp document send path
by giannisanni · 2026-02-01
92.4%
#10889: fix: pass fileName through WhatsApp document send path
by DeveshParagiri · 2026-02-07
91.7%
#7458: fix: pass filename through to WhatsApp document sends (#7446)
by gavinbmoore · 2026-02-02
90.1%
#16785: fix(whatsapp): preserve document filenames in outbound Baileys mode
by SahilSahu731 · 2026-02-15
89.7%
#9606: fix: pass fileName to WhatsApp document messages
by AytuncYildizli · 2026-02-05
89.2%
#21881: fix(whatsapp): pass user-provided fileName through document send pipe…
by saakshigupta2002 · 2026-02-20
88.9%
#16817: fix(whatsapp): infer extension-aware fallback filename for Baileys ...
by VintLin · 2026-02-15
88.0%
#8705: feat(whatsapp): add viewOnce support for ephemeral media
by ndohuu · 2026-02-04
78.5%
#23579: feat(whatsapp): add sender attribution to inbound message logs
by svan058 · 2026-02-22
78.0%
#16608: feat(whatsapp): resolve outbound @mentions to clickable WhatsApp me...
by lucasmpramos · 2026-02-14
76.8%