#11160: Media: add missing audio MIME-to-extension mappings (aac, flac, opus, wav)
stale
Cluster:
Media Handling Improvements
## Summary
Fixes #11066
Signal voice notes arrive as raw AAC streams (`audio/aac`) without a file extension. The `EXT_BY_MIME` map in `src/media/mime.ts` was missing entries for `audio/aac`, `audio/flac`, `audio/opus`, and `audio/wav`, so `extensionForMime()` returned `undefined` for these MIME types. This caused `saveMediaBuffer` to save files without an extension, which in turn prevented `isAudioFileName` from recognizing them and broke automatic transcription.
## Changes
- **`src/media/mime.ts`**: Add `audio/aac` → `.aac`, `audio/flac` → `.flac`, `audio/opus` → `.opus`, `audio/wav` → `.wav` to `EXT_BY_MIME`.
- **`src/media/mime.test.ts`**: Add test coverage for the new mappings.
- **`CHANGELOG.md`**: Add entry under Fixes.
## Root Cause
When Signal sends a voice note, the attachment arrives with `contentType: "audio/aac"` but no filename or extension. The media store calls `extensionForMime("audio/aac")` to determine the file extension, but this MIME type had no entry in `EXT_BY_MIME`. The file was saved as a bare UUID (no extension), so downstream checks like `isAudioFileName()` returned `false` and the transcription pipeline skipped it.
## Testing
- `pnpm test` — all 5028 tests pass (14 pre-existing feishu failures unrelated)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR extends the `EXT_BY_MIME` mapping in `src/media/mime.ts` to cover additional audio types (`audio/aac`, `audio/flac`, `audio/opus`, `audio/wav`) so that extensionless audio attachments can be saved with a correct extension. This aligns with downstream logic like `isAudioFileName()` (which keys off file extensions) and unblocks audio-specific behavior such as transcription.
Test coverage is updated in `src/media/mime.test.ts` to assert the new mappings, and the changelog includes a corresponding fix entry.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Changes are small, localized to MIME/extension mapping, consistent with existing patterns, and covered by targeted unit tests. No behavioral changes beyond returning extensions for previously-unmapped MIME types.
- No files require special attention
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#5401: fix(media-understanding): detect audio binary by magic bytes to pre...
by RiadJamal07 · 2026-01-31
78.4%
#7454: fix: skip UTF-16 heuristic for audio/video/image MIME types (#7444)
by gavinbmoore · 2026-02-02
77.2%
#18811: fix(media): require file extension for ambiguous MEDIA: path detection
by aldoeliacim · 2026-02-17
77.1%
#14794: fix: parse inline MEDIA: tokens in agent replies
by explainanalyze · 2026-02-12
76.2%
#4235: fix(media): skip audio in extractFileBlocks + hasBinaryAudioMagic d...
by null-runner · 2026-01-29
75.9%
#8388: fix(media): auto-skip tiny/empty audio files before transcription (...
by Glucksberg · 2026-02-04
75.7%
#8048: Media: add regression test for audio text blocks (#7970)
by Abhishek-B-R · 2026-02-03
75.7%
#10257: fix(security): anchor MIME sanitization regex and block fullwidth b...
by nu-gui · 2026-02-06
75.1%
#11443: LINE: fix buffer guards in detectContentType + add tests
by MdRahmatUllah · 2026-02-07
75.1%
#15770: fix: prevent phantom <media:unknown> messages from Signal protocol ...
by joetomasone · 2026-02-13
74.9%