Skip to content

normalizeStoredSpeakerCount accepts boolean true and array values as valid speaker counts #1833

Description

@hsusul

Describe the bug

In src/helpers/speakerCount.js:

normalizeStoredSpeakerCount(value) converts its input using const count = Number(value) and checks Number.isInteger(count) && count >= 1.

In JavaScript:

  • Number(true) is 1, so normalizeStoredSpeakerCount(true) returns 1.
  • Number(["2"]) is 2, so normalizeStoredSpeakerCount(["2"]) returns 2.

When non-numeric types (such as booleans or arrays) arrive via cloud sync or loosely structured stored data, normalizeStoredSpeakerCount erroneously returns an integer instead of degrading to null.

To Reproduce

  1. Call normalizeStoredSpeakerCount(true) -> returns 1 (expected null).
  2. Call normalizeStoredSpeakerCount(["2"]) -> returns 2 (expected null).

Expected Behavior

normalizeStoredSpeakerCount should only accept numbers or numeric strings (typeof value === "number" || typeof value === "string"), returning null for booleans, arrays, and other non-numeric types.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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