← Back to PRs

#11160: Media: add missing audio MIME-to-extension mappings (aac, flac, opus, wav)

by lailoo open 2026-02-07 13:39 View on GitHub →
stale
## 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