{"record":{"id":"8771a76721b290bb","repo":"paperclipai/paperclip","slug":"choose-one-option","errorCode":null,"errorMessage":"Choose one option","messagePattern":"Choose one option","errorType":"validation","errorClass":"PhotonAnswerValidationError","httpStatus":null,"severity":"error","filePath":"server/src/services/photon/interactions.ts","lineNumber":107,"sourceCode":"  if (!value || value.length > 100_000)\n    throw new PhotonAnswerValidationError(\n      \"Enter a nonempty answer within the task’s length limit\",\n    );\n  const numbers =\n    /^\\d+(?:[ ,]+\\d+)*$/.test(value) &&\n    question.options.some((option) => !option.freeText)\n      ? value.split(/[ ,]+/).map(Number)\n      : null;\n  if (numbers) {\n    if (\n      new Set(numbers).size !== numbers.length ||\n      numbers.some((index) => index < 1 || index > question.options.length)\n    )\n      throw new PhotonAnswerValidationError(\n        \"Choose valid option numbers without duplicates\",\n      );\n    if (question.selectionMode === \"single\" && numbers.length !== 1)\n      throw new PhotonAnswerValidationError(\"Choose one option\");\n    if (numbers.some((index) => question.options[index - 1].freeText))\n      throw new PhotonAnswerValidationError(\"Write your custom answer as text\");\n    return {\n      questionId: question.id,\n      optionIds: numbers.map((index) => question.options[index - 1].id),\n    };\n  }\n  const freeText = question.options.find((option) => option.freeText);\n  if (question.options.length && question.allowOther === false && !freeText)\n    throw new PhotonAnswerValidationError(\n      \"Answer with the option number(s) shown in the prompt\",\n    );\n  return {\n    questionId: question.id,\n    optionIds: freeText ? [freeText.id] : [],\n    otherText: value,\n  };\n}","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/server/src/services/photon/interactions.ts#L89-L125","documentation":"PhotonAnswerValidationError thrown when a question with selectionMode 'single' receives a numeric answer selecting more than one option number. Single-select questions accept exactly one option number.","triggerScenarios":"Calling parsePhotonQuestionAnswer with multiple numbers (e.g. \"1 3\") on a question whose payload has selectionMode === 'single'.","commonSituations":"UI allows multi-select controls for a single-select question; agent tries to select several options in one answer; question type changed from multi to single after the UI rendered.","solutions":["Send exactly one option number for single-select questions","Check question.selectionMode before composing the answer; use multi numbers only when it is 'multiple'","If multiple selections are genuinely intended, change the question's selectionMode to 'multiple' and republish"],"exampleFix":"// before\nawait answer(interaction, index, \"1 2\");\n// after\nconst value = question.selectionMode === \"single\" ? \"1\" : \"1 2\";\nawait answer(interaction, index, value);","handlingStrategy":"validation","validationCode":"if (question.selectionMode === 'single' && selectedNumbers.length !== 1) throw new Error('choose exactly one option');","typeGuard":null,"tryCatchPattern":"try { return parsePhotonQuestionAnswer(interaction, i, value); } catch (e) { if (e instanceof PhotonAnswerValidationError && e.message === 'Choose one option') return enforceSingleSelect(question); throw e; }","preventionTips":["Render radio inputs (single pick) when selectionMode is 'single'","Check selectionMode before enabling multi-select","Strip extra numbers for single-select questions"],"tags":["validation","single-select","option-selection"],"backgroundTag":"invalid-argument-value","analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}