← Back to PRs

#16817: fix(whatsapp): infer extension-aware fallback filename for Baileys documents

by VintLin open 2026-02-15 04:44 View on GitHub →
channel: whatsapp-web size: XS
# 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