{"record":{"id":"56763e5340a1acf4","repo":"Yeachan-Heo/oh-my-codex","slug":"answers-entry-index-answer-kind-option-is-only","errorCode":null,"errorMessage":"answers[${entry.index}].answer.kind=option is only valid for single-answerable questions","messagePattern":"answers\\[(.+?)\\]\\.answer\\.kind=option is only valid for single-answerable questions","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/question/state.ts","lineNumber":385,"sourceCode":"  const outOfSchemaValues = selectedValues.filter((value) => !optionValues.has(value));\n\n  if (answer.kind === 'other') {\n    if (!question.allow_other) throw new Error(`answers[${entry.index}].answer.kind=other is not allowed for this question`);\n    if (multi) throw new Error(`answers[${entry.index}].answer.kind=other is only valid for single-answerable questions`);\n    if (!otherText) throw new Error(`answers[${entry.index}].answer.other_text must be a non-empty string`);\n    if (selectedValues.length !== 1 || selectedValues[0] !== otherText || answer.value !== otherText) {\n      throw new Error(`answers[${entry.index}].answer other value must match selected_values[0] and other_text`);\n    }\n    assertSelectedLabelsMatch(\n      selectedLabels,\n      [question.other_label],\n      `answers[${entry.index}].answer.selected_labels`,\n    );\n    return;\n  }\n\n  if (answer.kind === 'option') {\n    if (multi) throw new Error(`answers[${entry.index}].answer.kind=option is only valid for single-answerable questions`);\n    if (selectedValues.length !== 1 || selectedLabels.length !== 1) {\n      throw new Error(`answers[${entry.index}].answer must select exactly one option`);\n    }\n    const selectedValue = selectedValues[0]!;\n    if (!optionValues.has(selectedValue)) {\n      throw new Error(`answers[${entry.index}].answer selected value is not in the option schema: ${selectedValue}`);\n    }\n    if (answer.value !== selectedValue) {\n      throw new Error(`answers[${entry.index}].answer.value must match selected_values[0]`);\n    }\n    assertSelectedLabelsMatch(\n      selectedLabels,\n      expectedSelectedLabelsForValues(question, selectedValues, undefined),\n      `answers[${entry.index}].answer.selected_labels`,\n    );\n    return;\n  }\n","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/question/state.ts#L367-L403","documentation":"Answers with kind 'option' represent a single choice and are only valid for single-answerable questions. Submitting kind 'option' to a multi-answerable (multi_select) question throws, because multi questions must use kind 'multi'.","triggerScenarios":"answer.kind === 'option' while isMultiAnswerableQuestion(question) is true.","commonSituations":"Client defaulting to kind 'option' for every selection; question schema changed to multi_select after client written; single-select component reused for a multi question.","solutions":["Use kind 'multi' with array value/selected_values for multi_select questions","Branch answer.kind on question.multi_select"],"exampleFix":"// before\nanswer.kind = 'option'; answer.value = v; answer.selected_values = [v];\n// after\nif (question.multi_select) { answer.kind = 'multi'; answer.value = vals; answer.selected_values = vals; }\nelse { answer.kind = 'option'; answer.value = v; answer.selected_values = [v]; }","handlingStrategy":"type-guard","validationCode":"if (answer.kind === 'option' && isMulti(question)) throw new Error('multi question requires kind=multi');","typeGuard":"function isMulti(q: NormalizedQuestionItem): boolean { return !!q.multi_select; }","tryCatchPattern":"try { await submit(p, answers); } catch (e) { if (/kind=option is only valid for single-answerable/.test((e as Error).message)) { convertToMulti(answer); return submit(p, answers); } throw e; }","preventionTips":["Choose answer.kind from question.multi_select in a single builder function","Rebuild the answer whenever the question type changes"],"tags":["validation","multi-select","answers"],"backgroundTag":"schema-validation-failed","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}