#16817: fix(whatsapp): infer extension-aware fallback filename for Baileys documents
channel: whatsapp-web
size: XS
Cluster:
WhatsApp Document Handling Fixes
# Problem
WhatsApp document sends in Baileys mode can fall back to a generic `fileName: "file"` when no explicit filename is provided. For PDF attachments this may appear as a generic `file` label instead of a meaningful file name.
# Changes
- Keep explicit `sendOptions.fileName` precedence unchanged.
- Add `resolveDocumentFileName()` in `src/web/inbound/send-api.ts` to derive an extension-aware fallback from MIME when filename is absent.
- Example: `application/pdf` → `file.pdf`
- Update fallback unit test expectation in `src/web/inbound/send-api.test.ts`.
# Validation
- `pnpm vitest run src/web/inbound/send-api.test.ts src/web/outbound.test.ts`
- Result: 2 files passed, 11 tests passed.
# Risk & Rollback
- Scope is limited to the WhatsApp document fallback path in Baileys send payload construction.
- Explicit filenames are untouched.
- Rollback: revert this PR (2-file change).
Refs #16768
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds a MIME-aware fallback filename for WhatsApp document sends via Baileys, so documents like PDFs get a `file.pdf` label instead of the generic `file` when no explicit filename is provided.
- Introduces a private `resolveDocumentFileName()` helper in `src/web/inbound/send-api.ts` that uses the existing `extensionForMime()` utility to derive a file extension from the MIME type
- Preserves existing behavior: explicit `sendOptions.fileName` takes precedence, and unknown MIME types still fall back to `"file"`
- Test updated to assert the new `file.pdf` fallback for `application/pdf` documents
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — it's a minimal, well-scoped fallback improvement with no risk to existing behavior.
- The change is small (a single private helper function replacing an inline expression), leverages an existing well-tested utility (`extensionForMime`), preserves backward compatibility (explicit filenames and unknown MIME types are unaffected), and includes a corresponding test update. No logical errors or edge case issues found.
- No files require special attention.
<sub>Last reviewed commit: 0419637</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#15650: fix(whatsapp): pass fileName to document sends instead of hardcodin...
by whoknowsmann · 2026-02-13
88.0%
#6566: fix: thread fileName through WhatsApp document send path
by giannisanni · 2026-02-01
86.4%
#7458: fix: pass filename through to WhatsApp document sends (#7446)
by gavinbmoore · 2026-02-02
85.9%
#21881: fix(whatsapp): pass user-provided fileName through document send pipe…
by saakshigupta2002 · 2026-02-20
85.5%
#16785: fix(whatsapp): preserve document filenames in outbound Baileys mode
by SahilSahu731 · 2026-02-15
85.3%
#10889: fix: pass fileName through WhatsApp document send path
by DeveshParagiri · 2026-02-07
83.8%
#9606: fix: pass fileName to WhatsApp document messages
by AytuncYildizli · 2026-02-05
83.2%
#7395: fix(whatsapp): strip markdown bold/italic from URLs before sending
by lailoo · 2026-02-02
76.2%
#8705: feat(whatsapp): add viewOnce support for ephemeral media
by ndohuu · 2026-02-04
76.0%
#23579: feat(whatsapp): add sender attribution to inbound message logs
by svan058 · 2026-02-22
75.2%