fix(audio): guard evaluateFinishedRecording against null and non-object parameters - #1840
fix(audio): guard evaluateFinishedRecording against null and non-object parameters#1840hsusul wants to merge 1 commit into
Conversation
|
Thanks for the careful work here, @hsusul — the tests are well written and the verification checklist (typecheck, lint, i18n, build) is genuinely appreciated. I'm going to close this one, along with #1839, for a reason that's about our conventions rather than your code: There's also a subtle reason we prefer the current behavior: if a future refactor ever did pass Thanks again, and please keep the contributions coming! 🙏 |
|
One general note, since you've clearly got an eye for edge cases: our convention (CLAUDE.md) is to validate exactly once, at real trust boundaries — IPC payloads arriving from the renderer, external API responses not already mediated by a typed SDK, persisted data an older app version could have written in a different shape, user-editable files — and to trust internal callers past that point, so that impossible states fail loudly instead of being silently coerced. Hardening PRs at those boundaries are very welcome! The strongest ones start from an observable app behavior (a crash log, a repro via real user actions) rather than a direct helper call. Would love to see more contributions in that direction — thanks for the energy you're putting into OpenWhispr. |
Fixes #1839
Problem
In
src/helpers/recordingValidation.js:evaluateFinishedRecording({ blobSize, receivedAudioData } = {})threwTypeError: Cannot destructure property 'blobSize' of 'null' as it is nullwhen passednull.Solution
nulland non-object parameters safely usingparams && typeof params === "object" ? params : {}.test/helpers/recordingValidation.test.js.Verification
node --test test/helpers/recordingValidation.test.js(passes, 10/10 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)