#22540: fix(signal): preserve original filename in outbound attachments
size: S
experienced-contributor
Cluster:
WhatsApp Document Handling Fixes
## Summary
- **Bug**: Signal outbound attachments arrive with UUID-only filenames instead of the original filename
- **Root cause**: `resolveOutboundAttachmentFromUrl` in `src/media/outbound-attachment.ts` discards `media.fileName` returned by `loadWebMedia`, never passing it to `saveMediaBuffer`
- **Fix**: Pass `media.fileName` as the `originalFilename` parameter to `saveMediaBuffer`
Fixes #22487
## Problem
When sending a file via Signal, the file arrives in the recipient's client with a UUID name (e.g. `533d51fb-ca5b-42ef-ab0d-a1bc68e10892.zip`) instead of the original filename.
The root cause is in `resolveOutboundAttachmentFromUrl`:
1. `loadWebMedia()` returns `{ buffer, contentType, kind, fileName }` — `fileName` is populated from `path.basename(mediaUrl)`
2. `saveMediaBuffer()` already supports an `originalFilename` parameter (5th arg) that embeds the name in the stored path as `{sanitized}---{uuid}.ext`
3. But `resolveOutboundAttachmentFromUrl` never passes `media.fileName` through — it calls `saveMediaBuffer` with only 4 args
**Before fix:**
```
Input: mediaUrl = "/path/to/MyDocument.txt"
Output: saved path = "07ea27ef-66d6-4da8-918d-bcef93d25a5c.txt"
```
## Changes
- `src/media/outbound-attachment.ts` — pass `media.fileName` to `saveMediaBuffer` as the 5th argument
- `src/media/outbound-attachment.test.ts` — new regression test
**After fix:**
```
Input: mediaUrl = "/path/to/MyDocument.txt"
Output: saved path = "MyDocument---711c4d08-d9f5-4b7e-82d3-ee49bdebce7d.txt"
```
## Test plan
- [x] New test: `outbound-attachment.test.ts` — verifies filename preservation for normal files and extensionless files
- [x] All 18 existing `store.test.ts` tests pass
- [x] Format check passes (`oxfmt --check`)
## Effect on User Experience
**Before:** Every file sent via Signal arrives with a UUID filename (e.g. `533d51fb-...-.zip`), confusing recipients who download the file.
**After:** Files arrive with their original filename preserved (e.g. `MyDocument.zip`).
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes Signal outbound attachments to preserve original filenames instead of UUID-only names. The fix passes `media.fileName` from `loadWebMedia` through to `saveMediaBuffer` as the 5th argument (`originalFilename`), enabling the existing filename-embedding feature that creates paths like `MyDocument---{uuid}.txt` instead of just `{uuid}.txt`.
- Fixed `src/media/outbound-attachment.ts:18` by adding `media.fileName` as the 5th parameter to `saveMediaBuffer`
- Added regression tests in `src/media/outbound-attachment.test.ts` covering normal files and extensionless files
- Updated `CHANGELOG.md` with user-facing fix description
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The fix is a simple one-line change that passes an existing parameter to an already-tested function. The `saveMediaBuffer` function already has comprehensive test coverage for the `originalFilename` parameter (lines 236-303 in `store.test.ts`), and the new regression tests verify the end-to-end behavior. The change is backwards-compatible (passing `undefined` falls back to UUID-only behavior), and the logic matches the PR description perfectly.
- No files require special attention
<sub>Last reviewed commit: 5505e23</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#12381: fix(telegram): preserve original filename for inbound documents
by thebtf · 2026-02-09
77.7%
#21881: fix(whatsapp): pass user-provided fileName through document send pipe…
by saakshigupta2002 · 2026-02-20
76.0%
#15650: fix(whatsapp): pass fileName to document sends instead of hardcodin...
by whoknowsmann · 2026-02-13
75.4%
#6591: fix(signal): process all inbound attachments in parallel
by ProofOfReach · 2026-02-01
75.0%
#7458: fix: pass filename through to WhatsApp document sends (#7446)
by gavinbmoore · 2026-02-02
74.8%
#10958: fix: Signal UUID allowlist entries silently fail when sourceNumber ...
by meaadore1221-afk · 2026-02-07
74.7%
#9606: fix: pass fileName to WhatsApp document messages
by AytuncYildizli · 2026-02-05
74.3%
#15770: fix: prevent phantom <media:unknown> messages from Signal protocol ...
by joetomasone · 2026-02-13
74.2%
#16785: fix(whatsapp): preserve document filenames in outbound Baileys mode
by SahilSahu731 · 2026-02-15
74.1%
#10889: fix: pass fileName through WhatsApp document send path
by DeveshParagiri · 2026-02-07
74.1%