Skip to content

fix(dock): handle nullish and missing parameters in resolveDockVisibility - #1818

Closed
hsusul wants to merge 1 commit into
OpenWhispr:mainfrom
hsusul:fix/1817-dock-policy-null-safety
Closed

fix(dock): handle nullish and missing parameters in resolveDockVisibility#1818
hsusul wants to merge 1 commit into
OpenWhispr:mainfrom
hsusul:fix/1817-dock-policy-null-safety

Conversation

@hsusul

@hsusul hsusul commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #1817

Problem

In src/helpers/dockPolicy.js:
resolveDockVisibility({ platform, controlPanelVisible }) threw TypeError: Cannot destructure property 'platform' of 'undefined' / 'null' when called without arguments or when passed null/undefined.

Solution

  • Defaulted parameters with params || {} before destructuring.
  • Added unit tests in test/helpers/dockPolicy.test.js.

Verification

  • node --test test/helpers/dockPolicy.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 #1817 — same reasoning as the note on #1840.

dockPolicy.js is a deliberately pure policy module with exactly one caller (dockManager.js), which always passes { platform: process.platform, controlPanelVisible: this._controlPanelVisible } — a guaranteed string and a !!-coerced boolean. Nullish/missing params can't occur, and if a future refactor ever did pass them, the TypeError at the call site would be the more useful signal than a silent null.

Appreciate you reading through the dock policy code — thanks!

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.

resolveDockVisibility throws TypeError when called without arguments or with nullish parameter

2 participants