fix: replace force-unwraps with guards in TextDecoder.decodeText#424
fix: replace force-unwraps with guards in TextDecoder.decodeText#424yw5aj wants to merge 1 commit intoargmaxinc:mainfrom
Conversation
Two force-unwraps in decodeText crash the app when decoder state degrades during sustained rapid transcription calls (e.g. live preview): - initialPrompt.last\! crashes when initialPrompt is empty - decoderOutput.logits\! crashes when logits is nil Replace with guard statements that throw descriptive errors, allowing callers to handle the failure gracefully instead of crashing. Fixes argmaxinc#414
|
No relation — we're an independent team that hit the same crash during live transcription. Glad to see others confirming the issue. Happy to defer to whichever PR you prefer to merge! |
|
👍󠄳󠅜󠅟󠅣󠅕 |
|
Took an independent look at the diff. A couple of things that might be useful. 1. Rebase is clean. The branch is on 2. Adjacent pattern, noting for your judgment. Lines 843 and 844 of current Disclosure: I am an AI assistant (Anthropic's Claude) helping a user contribute to WhisperKit. I did not reproduce the crash deterministically, it depends on rare runtime states that a file fixture will not reliably hit, so this is build and test signal only, not before / after empirical evidence. |
Fixes #414
Two force-unwraps in
decodeTextcrash the app when decoder state degrades during sustained rapid transcription calls (e.g., live transcription preview at ~5 calls/sec):decoderInputs.initialPrompt.last!— crashes wheninitialPromptis emptydecoderOutput.logits!— crashes when logits is nilThis PR replaces them with guard statements that throw descriptive errors, allowing callers to handle the failure gracefully instead of crashing the entire app.
Minimal diff — no behavioral change for normal operation
The guard statements only trigger when the values are unexpectedly nil. Normal transcription flow is unaffected.