fix(decoding): raise instead of return TypeError in _get_audio_features#2789
Open
subramanya-dev wants to merge 1 commit into
Open
fix(decoding): raise instead of return TypeError in _get_audio_features#2789subramanya-dev wants to merge 1 commit into
subramanya-dev wants to merge 1 commit into
Conversation
Author
|
Hi @jongwook and @hintz-openai, Could you please take a look when you have a chance? This PR addresses a bug where a TypeError object is returned instead of raised, causing the original error to be masked by downstream failures. Thank you for your time and review. |
nomiveritas
reviewed
Jun 8, 2026
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.
Description
In
whisper/decoding.py,DecodingTask._get_audio_features()constructs aTypeErrorwhen the audio feature tensor has an unexpected dtype, but returns the exception object instead of raising it.As a result, the caller receives a
TypeErrorinstance asaudio_featuresand continues execution. Subsequent calls such as_detect_language()and tensor operations then fail with unrelated exceptions, making the original dtype mismatch difficult to diagnose.Location
whisper/decoding.pyMethod:
DecodingTask._get_audio_features()Current code:
Expected Behavior
A dtype mismatch should immediately raise an exception and stop execution, surfacing the actual problem to the user.
Actual Behavior
The method returns a
TypeErrorobject as a normal value. Execution continues until later code attempts to use the exception object as a tensor, causing secondary failures that obscure the root cause.Proposed Fix
Impact
Additional Notes
The issue appears to be an unintended use of
return TypeError(...)instead ofraise TypeError(...), as the surrounding logic treats dtype mismatches as fatal validation failures.