fix: UnboundLocalError in transcribe when cloud + include_text=false#238
Open
javidjamae wants to merge 1 commit into
Open
fix: UnboundLocalError in transcribe when cloud + include_text=false#238javidjamae wants to merge 1 commit into
javidjamae wants to merge 1 commit into
Conversation
When response_type is "cloud" and include_text is false, the else branch
assigned `text_file = None` but the function returns `text_filename` on
line 153, raising `UnboundLocalError: cannot access local variable
'text_filename' where it is not associated with a value`.
Reproducible via any call asking the toolkit for SRT-only cloud output:
POST /v1/media/transcribe
{
"media_url": "https://.../audio.mp3",
"response_type": "cloud",
"include_text": false,
"include_srt": true
}
Fix: assign the correct variable name in the else branch.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
process_transcribe_mediainservices/v1/media/media_transcribe.pyraisesUnboundLocalErrorwhenever a caller asks for cloud-mode output without text.The
elsebranch at line 137 assignstext_file = None(wrong name), but line 153 returnstext_filename. In the common case ofinclude_text=Truethe bug is hidden because theifbranch assignstext_filenamefor real. The moment you disableinclude_textin cloud mode, Python bails out with:Reproduction
POST /v1/media/transcribe { "media_url": "https://.../speech.mp3", "response_type": "cloud", "include_text": false, "include_srt": true }The job is queued, Whisper transcribes, then the upload step explodes with the UnboundLocalError above and the job is marked failed.
Fix
One-line typo fix — bind
text_filename = Nonein theelsebranch so the return statement sees a defined name.Test plan
upstream/main(d9bb567) using SRT-only cloud mode.{ srt_url, text_url: null, segments_url: null }as expected.include_text=Truepath still behaves identically (theifbranch was already correct).🤖 Generated with Claude Code