NousResearch/hermes-agent · error

question is required

Error message

question is required

What it means

Thrown by buildPollPayload when the WhatsApp poll has no usable question after trimming — question missing, empty, or whitespace-only. WhatsApp polls require a non-empty name, so the bridge refuses to construct the Baileys poll message without one.

Source

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

      return { image: buffer, caption: caption || undefined, mimetype: MIME_MAP[ext] || 'image/jpeg' };
    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);

View on GitHub (pinned to c896c09c42)

Solutions

  1. Provide a non-empty question string in the poll payload.
  2. Require question in the tool/schema definition (minLength 1) so callers cannot omit it.
  3. Trim and validate at the call site and prompt the user/agent for a title when empty.

Example fix

// before
buildPollPayload({ options: ['A', 'B'] })

// after
buildPollPayload({ question: 'Lunch?', options: ['Pizza', 'Sushi'] })
Defensive patterns

Strategy: validation

Validate before calling

function hasPollQuestion(q: unknown): boolean {
  return typeof q === 'string' && q.trim().length > 0
}

Type guard

function isNonEmptyQuestion(q: unknown): q is string {
  return typeof q === 'string' && q.trim().length > 0
}

Try / catch

try {
  buildPollPayload(args)
} catch (e) {
  if (e instanceof Error && e.message === 'question is required')
    reply('A poll needs a question.')
  else throw e
}

Prevention

When it happens

Trigger: Sending a poll via the bridge with question omitted, an empty string, or only spaces; or an LLM tool call that puts the poll text into options and leaves question blank.

Common situations: Malformed agent/tool payload for send-poll, or a UI form allowing empty poll title submission.

Related errors


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