← Back to PRs

#8388: fix(media): auto-skip tiny/empty audio files before transcription (#8127)

by Glucksberg open 2026-02-04 00:24 View on GitHub →
size: M experienced-contributor
Fixes #8127 When tiny or empty audio files are sent for transcription, the Whisper API returns unhelpful errors. **Changes:** - Added `MIN_AUDIO_FILE_BYTES = 1024` constant - Added `"tooSmall"` to `MediaUnderstandingSkipReason` - File size guard in both provider path (`runProviderEntry`) and CLI path (`runCliEntry`) - Files below 1KB are skipped with a descriptive `MediaUnderstandingSkipError` - 3 new tests (tiny file skip, empty file skip, valid file proceeds) - Updated existing test fixtures to use buffers above the threshold <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> Adds a minimum-audio-size guard (`MIN_AUDIO_FILE_BYTES = 1024`) so tiny/empty audio attachments are skipped before being sent to transcription providers/CLI, returning a `MediaUnderstandingSkipError` with new reason `tooSmall`. Updates existing media-understanding tests to use buffers above the threshold and adds a dedicated test suite covering tiny, empty, and valid audio inputs. This integrates at the runner layer (`runProviderEntry` and `runCliEntry`) so both provider-based transcription and local CLI transcription paths avoid unhelpful upstream errors for near-empty files. <h3>Confidence Score: 4/5</h3> - This PR is likely safe to merge; the core guard is simple and well-covered by tests. - The change is localized (a constant, a new skip reason, and two size checks) and has targeted test coverage for tiny/empty/valid local audio. Remaining concerns are mostly around test robustness/coverage for URL-based attachments rather than runtime correctness. - src/media-understanding/runner.skip-tiny-audio.test.ts (assertion robustness), src/media-understanding/apply.test.ts (remote/URL tiny-audio coverage) <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs