Skip to content

fix(members): safely handle null or missing email in filterMemberCandidates #1449

Description

@hsusul

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

  1. Update filterMemberCandidates in src/lib/memberCandidates.ts to type email as email?: string | null and safely use (member.email ?? ).toLowerCase().
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions