Skip to content

app: don't fail audio export when one WAV part is corrupt (missing RIFF)#9335

Open
mdmohsin7 wants to merge 2 commits into
mainfrom
caleb/fix-wav-riff-combine
Open

app: don't fail audio export when one WAV part is corrupt (missing RIFF)#9335
mdmohsin7 wants to merge 2 commits into
mainfrom
caleb/fix-wav-riff-combine

Conversation

@mdmohsin7

@mdmohsin7 mdmohsin7 commented Jul 9, 2026

Copy link
Copy Markdown
Member

Problem

Sharing a multi-part WAV conversation could fail entirely with:

Exception: Invalid WAV file: missing RIFF header

WavCombiner.combineWavFiles parsed every part up front and threw on the first one that wasn't a canonical WAV, aborting the whole export — the user got "failed to download audio" instead of their recording.

The backend serves canonical pcm_to_wav WAVs, so this is a bad/stale/mislabeled part slipping through; regardless of the exact cause, one bad part shouldn't nuke the entire share.

Scope / data

Fix

combineWavFiles now parses each part in a try/catch, skips any that don't parse as valid WAV (logging which), and combines the rest. It only throws when no part is valid. This mirrors the existing "degrade gracefully rather than produce a corrupt file / hard-fail" behavior already in the download service's mixed-format branch.

Tests

test/utils/wav_combiner_test.dart (4 cases): combine valid parts; skip a missing-RIFF part and combine the rest; return the lone valid part when the others are corrupt; throw only when none are valid. All pass.

Verification

  • flutter analyze: no errors/warnings.
  • flutter test test/utils/wav_combiner_test.dart: 4/4 pass.

Review in cubic

mdmohsin7 added 2 commits July 9, 2026 14:32
A single part that isn't a valid WAV (e.g. a stale/mislabeled artifact)
threw 'Invalid WAV file: missing RIFF header' and failed the entire
multi-part audio share. Skip unparseable parts and combine the ones that
do parse; only fail when none are valid.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mobile bug fix: skip corrupt WAV part in multi-part export instead of hard-failing; has test. Approve (Android Compile Smoke red blocks merge).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants