NousResearch/hermes-agent · error

at least two poll options are required

Error message

at least two poll options are required

What it means

Thrown by buildPollPayload when, after trimming and dropping empty entries, fewer than two poll options remain. WhatsApp requires at least two choices for a meaningful poll; likewise the helper caps options at 12 (a separate error). Empty-string options are filtered out, so ['A', ''] also triggers it.

Source

Thrown at scripts/whatsapp-bridge/bridge_helpers.js:539

    case 'video':
      return { video: buffer, caption: caption || undefined, mimetype: MIME_MAP[ext] || 'video/mp4' };
    case 'document':
      return {
        document: buffer,
        fileName: fileName || path.basename(filePath),
        caption: caption || undefined,
        mimetype: MIME_MAP[ext] || 'application/octet-stream',
      };
    default:
      return null;
  }
}

export function buildPollPayload({ question, options, selectableCount = 1 }) {
  const cleanQuestion = String(question || '').trim();
  const cleanOptions = (options || []).map(option => String(option || '').trim()).filter(Boolean);
  if (!cleanQuestion) throw new Error('question is required');
  if (cleanOptions.length < 2) throw new Error('at least two poll options are required');
  if (cleanOptions.length > 12) throw new Error('at most 12 poll options are supported');
  const count = Math.max(1, Math.min(Number(selectableCount) || 1, cleanOptions.length));
  return {
    poll: {
      name: cleanQuestion,
      values: cleanOptions,
      selectableCount: count,
      messageSecret: randomBytes(32),
    },
  };
}

export function pollCreationMessageFromPayload(payload) {
  const poll = payload?.poll;
  if (!poll) return null;
  const values = Array.isArray(poll.values) ? poll.values : [];
  const options = values.map(value => String(value || '').trim()).filter(Boolean);
  if (!poll.name || options.length < 2) return null;

View on GitHub (pinned to c896c09c42)

Solutions

  1. Supply at least two non-empty, distinct options in the payload.
  2. Pass options as an array of strings, not a single delimited string.
  3. Filter/validate options client-side (length >= 2 after trim) before invoking the bridge.

Example fix

// before
buildPollPayload({ question: 'OK?', options: ['yes'] })

// after
buildPollPayload({ question: 'OK?', options: ['yes', 'no'] })
Defensive patterns

Strategy: validation

Validate before calling

function hasEnoughOptions(options: unknown): boolean {
  return Array.isArray(options) && options.filter((o: unknown) => String(o ?? '').trim()).length >= 2
}

Type guard

function isPollOptionsArray(o: unknown): o is string[] {
  return Array.isArray(o) && o.filter(x => String(x ?? '').trim()).length >= 2 && o.length <= 12
}

Try / catch

try {
  buildPollPayload(args)
} catch (e) {
  if (e instanceof Error && e.message === 'at least two poll options are required')
    reply('A poll needs two or more non-empty options.')
  else throw e
}

Prevention

When it happens

Trigger: Sending a poll with 0 or 1 options, or with multiple options where all but one are blank/whitespace and get filtered.

Common situations: LLM-generated poll with a single yes-style option, options array passed as a comma-joined string by mistake, or blank entries from a sloppy form.

Related errors


AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14). Data as JSON: /api/errors/4a18bb93c593dce1. Report an issue: GitHub.