← Back to PRs

#6566: fix: thread fileName through WhatsApp document send path

by giannisanni open 2026-02-01 20:14 View on GitHub →
channel: whatsapp-web
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