Skip to content

fix(transcription): handle nullish params and normalize cloudTranscriptionMode in resolveStreamingFallbackTarget - #1830

Closed
hsusul wants to merge 1 commit into
OpenWhispr:mainfrom
hsusul:fix/1829-transcription-fallback-null-safety
Closed

fix(transcription): handle nullish params and normalize cloudTranscriptionMode in resolveStreamingFallbackTarget#1830
hsusul wants to merge 1 commit into
OpenWhispr:mainfrom
hsusul:fix/1829-transcription-fallback-null-safety

Conversation

@hsusul

@hsusul hsusul commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #1829

Problem

In src/helpers/transcriptionFallback.js:

  1. resolveStreamingFallbackTarget threw TypeError: Cannot destructure property 'useLocalWhisper' of 'undefined' / 'null' when called without arguments or passed null/undefined.
  2. cloudTranscriptionMode === "openwhispr" did not normalize casing or whitespace, treating "OpenWhispr" as non-cloud and returning "byok".

Solution

  • Defaulted parameters with params || {} before destructuring.
  • Normalized cloudTranscriptionMode with trim().toLowerCase().
  • Added unit tests in test/helpers/transcriptionFallback.test.js.

Verification

  • node --test test/helpers/transcriptionFallback.test.js (passes, 4/4 tests)
  • npm run typecheck (passes, 0 errors)
  • npm run lint (passes, 0 errors)
  • npm run i18n:check (passes)
  • npm run build:renderer (passes)
  • git diff --check (clean)

@Chadpiha

Copy link
Copy Markdown
Collaborator

Thanks @hsusul — closing with #1829 (same convention as the #1840 note).

The only caller passes getSettings(), which is a Zustand state snapshot and can't be nullish. And cloudTranscriptionMode is written as a lowercase literal by every write site in the app's history, so old localStorage can't hold a mixed-case value either. The deciding factor on the normalization half: this value is compared case-sensitively in ~15 other places (audioManager, dictationStreamingRouting, the settings store's own deriveTranscriptionMode, …). Normalizing in just this one reader would make the fallback route disagree with the streaming session router for the same stored value — if mixed case ever became real, the fix would belong at the write/store boundary so all readers stay consistent.

Thanks for the continued energy! 🙏

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.

resolveStreamingFallbackTarget throws TypeError when called without arguments and ignores mixed-case cloudTranscriptionMode

2 participants