fix(audio): bind tmp_wav before try in OpenAI transcribe() (#366)#392
fix(audio): bind tmp_wav before try in OpenAI transcribe() (#366)#392SAY-5 wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds a regression test suite that models the try/finally cleanup pattern in audio transcription. The tests demonstrate how an uninitialized local variable in a finally block can mask the original exception, and verify that pre-initializing the variable allows proper exception propagation. ChangesAudio Transcriber Error Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Ahmath-Gadji
left a comment
There was a problem hiding this comment.
Thank you for your contribution — I approve these changes.
Could you retarget the PR to the dev branch?
Our workflow is as the following: We merge features and bug fixes on dev, and once dev is stable and tested we rebase main on dev then proceed to a new release
|
Done, retargeted to dev. Thanks for the review. |
|
Retargeted to dev. Thanks! |
|
Retargeted to |
|
Retargeted to dev. Thanks! |
1 similar comment
|
Retargeted to dev. Thanks! |
|
Looks like the dev branch already initializes tmp_wav at the top of transcribe() since cbcd054, so this fix has effectively landed there. Happy for you to close this PR or, if you'd like the test coverage, I can rebase a tests-only commit. Let me know. |
Actually i think your commit is much needed as on dev is not initialized inside the try...catch block. It would be nice to have that test block aswell. See the current state of dev openrag/openrag/components/indexer/loaders/audio/openai.py Lines 44 to 49 in 7f4ada9 After rebase we will merge it |
When AudioSegment.from_file raises before tmp_wav is assigned, the finally clause that checks 'if tmp_wav' crashes with UnboundLocalError and masks the original exception, leaving operators with a confusing stack trace instead of the real decode error. Initialize tmp_wav = None ahead of the try block so the cleanup branch always sees the name. Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
c5e2566 to
49cc3a8
Compare
|
Rebased onto dev. The transcribe() fix already landed in dev, so the diff is now just the regression test (TestTranscribeFinallyCleanup) that exercises the buggy pattern vs the fixed pattern. |
Fixes #366.
AudioTranscriber.transcribe()only assignedtmp_wavinside the if/else block, so whenAudioSegment.from_fileraised before that point, thefinallyclause hitUnboundLocalErrorand masked the real decode failure.Move
tmp_wav = Noneahead of the try so the cleanup branch always sees the name; the real exception now propagates to the caller. Added a small regression test that mirrors the buggy / fixed control flow without pulling in the heavy ray / openai dependencies.Summary by CodeRabbit