Skip to content

Validate poll selection counts before sending polls #12

Description

@cubrift

Problem

The poll schema in messages/ai/schemas/AIMessagePollSchema.js accepts any numeric selectableCount, including zero, negative values, fractions, and values larger than the number of options. Invalid values can be rejected by WhatsApp/Baileys or create polls that do not behave as intended.

Expected behavior

A generated poll should always have a positive integer selection count that does not exceed the number of available options.

Suggested direction

Add numeric constraints to the schema and, if needed, a cross-field validation step that compares selectableCount with values.length.

Acceptance criteria

  • selectableCount must be an integer of at least 1.
  • It cannot exceed the number of poll options.
  • Invalid values are rejected before sock.sendMessage is called.
  • Valid single-select and multi-select polls continue to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcodexUse for codex-generated issues only.good first issueGood for newcomerswontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions