Affected Component
src/lib/memberCandidates.ts (filterMemberCandidates)
Actual Behavior
filterMemberCandidates assumes member.email is always a non-null string and calls member.email.toLowerCase(). If a workspace member or candidate object has a missing or null email (e.g. email: null or email: undefined), filtering candidate lists with any non-empty search string throws an uncaught TypeError: Cannot read properties of null (reading 'toLowerCase').
Expected Behavior
filterMemberCandidates should safely fall back to an empty string (member.email ?? ) when member.email is null or undefined, matching the safe handling already used for (member.name ?? ).
Environment
- Repository: OpenWhispr/openwhispr
- Branch: main (v1.8.1)
- Node.js 24+
User Impact
Searching or typing in member picker UI components (like MemberPickList) crashes the component or window if any candidate member in the list lacks an email address.
Root Cause Hypothesis
filterMemberCandidates uses (member.name ?? ).toLowerCase() for member names, but directly calls member.email.toLowerCase() for emails without checking for null or undefined. Additionally, the TypeScript interface parameter M requires email: string instead of allowing optional/nullish email email?: string | null.
Proposed Scope
- Update
filterMemberCandidates in src/lib/memberCandidates.ts to type email as email?: string | null and safely use (member.email ?? ).toLowerCase().
- Add deterministic unit tests in
test/lib/memberCandidates.test.js covering candidate objects with null or undefined emails.
I intend to submit a pull request with a fix and unit tests.
Affected Component
src/lib/memberCandidates.ts(filterMemberCandidates)Actual Behavior
filterMemberCandidatesassumesmember.emailis always a non-null string and callsmember.email.toLowerCase(). If a workspace member or candidate object has a missing ornullemail (e.g.email: nulloremail: undefined), filtering candidate lists with any non-empty search string throws an uncaughtTypeError: Cannot read properties of null (reading 'toLowerCase').Expected Behavior
filterMemberCandidatesshould safely fall back to an empty string(member.email ?? )whenmember.emailisnullorundefined, matching the safe handling already used for(member.name ?? ).Environment
User Impact
Searching or typing in member picker UI components (like
MemberPickList) crashes the component or window if any candidate member in the list lacks an email address.Root Cause Hypothesis
filterMemberCandidatesuses(member.name ?? ).toLowerCase()for member names, but directly callsmember.email.toLowerCase()for emails without checking fornullorundefined. Additionally, the TypeScript interface parameterMrequiresemail: stringinstead of allowing optional/nullish emailemail?: string | null.Proposed Scope
filterMemberCandidatesinsrc/lib/memberCandidates.tsto typeemailasemail?: string | nulland safely use(member.email ?? ).toLowerCase().test/lib/memberCandidates.test.jscovering candidate objects withnullorundefinedemails.I intend to submit a pull request with a fix and unit tests.