{"record":{"id":"365e8e4eea876656","repo":"NousResearch/hermes-agent","slug":"question-is-required","errorCode":null,"errorMessage":"question is required","messagePattern":"question is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/whatsapp-bridge/bridge_helpers.js","lineNumber":538,"sourceCode":"      return { image: buffer, caption: caption || undefined, mimetype: MIME_MAP[ext] || 'image/jpeg' };\n    case 'video':\n      return { video: buffer, caption: caption || undefined, mimetype: MIME_MAP[ext] || 'video/mp4' };\n    case 'document':\n      return {\n        document: buffer,\n        fileName: fileName || path.basename(filePath),\n        caption: caption || undefined,\n        mimetype: MIME_MAP[ext] || 'application/octet-stream',\n      };\n    default:\n      return null;\n  }\n}\n\nexport function buildPollPayload({ question, options, selectableCount = 1 }) {\n  const cleanQuestion = String(question || '').trim();\n  const cleanOptions = (options || []).map(option => String(option || '').trim()).filter(Boolean);\n  if (!cleanQuestion) throw new Error('question is required');\n  if (cleanOptions.length < 2) throw new Error('at least two poll options are required');\n  if (cleanOptions.length > 12) throw new Error('at most 12 poll options are supported');\n  const count = Math.max(1, Math.min(Number(selectableCount) || 1, cleanOptions.length));\n  return {\n    poll: {\n      name: cleanQuestion,\n      values: cleanOptions,\n      selectableCount: count,\n      messageSecret: randomBytes(32),\n    },\n  };\n}\n\nexport function pollCreationMessageFromPayload(payload) {\n  const poll = payload?.poll;\n  if (!poll) return null;\n  const values = Array.isArray(poll.values) ? poll.values : [];\n  const options = values.map(value => String(value || '').trim()).filter(Boolean);","sourceCodeStart":520,"sourceCodeEnd":556,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/scripts/whatsapp-bridge/bridge_helpers.js#L520-L556","documentation":"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.","triggerScenarios":"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.","commonSituations":"Malformed agent/tool payload for send-poll, or a UI form allowing empty poll title submission.","solutions":["Provide a non-empty question string in the poll payload.","Require question in the tool/schema definition (minLength 1) so callers cannot omit it.","Trim and validate at the call site and prompt the user/agent for a title when empty."],"exampleFix":"// before\nbuildPollPayload({ options: ['A', 'B'] })\n\n// after\nbuildPollPayload({ question: 'Lunch?', options: ['Pizza', 'Sushi'] })","handlingStrategy":"validation","validationCode":"function hasPollQuestion(q: unknown): boolean {\n  return typeof q === 'string' && q.trim().length > 0\n}","typeGuard":"function isNonEmptyQuestion(q: unknown): q is string {\n  return typeof q === 'string' && q.trim().length > 0\n}","tryCatchPattern":"try {\n  buildPollPayload(args)\n} catch (e) {\n  if (e instanceof Error && e.message === 'question is required')\n    reply('A poll needs a question.')\n  else throw e\n}","preventionTips":["Require question (minLength 1) in poll tool schemas.","Trim input in UI forms and block submit on empty titles.","Put poll text in question, choices in options — never both in options."],"tags":["whatsapp","bridge","poll","validation"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}