{"record":{"id":"25bf86079b91a29a","repo":"Yeachan-Heo/oh-my-codex","slug":"answers-entry-index-answer-kind-other-is-not-a","errorCode":null,"errorMessage":"answers[${entry.index}].answer.kind=other is not allowed for this question","messagePattern":"answers\\[(.+?)\\]\\.answer\\.kind=other is not allowed for this question","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/question/state.ts","lineNumber":370,"sourceCode":"    };\n  }\n  throw new Error(`answers[${entry.index}].question_id is unknown for this question: ${entry.question_id}`);\n}\n\nfunction validateAnswerAgainstQuestion(question: NormalizedQuestionItem, entry: QuestionAnswerEntry): void {\n  const { answer } = entry;\n  const selectedValues = validateStringArray(answer.selected_values, `answers[${entry.index}].answer.selected_values`);\n  const selectedLabels = validateStringArray(answer.selected_labels, `answers[${entry.index}].answer.selected_labels`);\n  assertNoDuplicateValues(selectedValues, `answers[${entry.index}].answer.selected_values`);\n\n  const optionValues = new Set(question.options.map((option) => option.value));\n  const multi = isMultiAnswerableQuestion(question);\n  const hasOtherText = typeof answer.other_text === 'string' && answer.other_text.trim().length > 0;\n  const otherText = hasOtherText ? answer.other_text!.trim() : undefined;\n  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    }","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/question/state.ts#L352-L388","documentation":"Answers with kind 'other' are only legal when the question schema sets allow_other. Submitting an other-kind answer to a question that does not allow it throws this error before any other validation.","triggerScenarios":"answer.kind === 'other' while question.allow_other is false/undefined; e.g. free-text fallback logic client-side that always sends kind 'other' when no option matches.","commonSituations":"Generic client code treating all questions as allow_other; question schema changed to disable allow_other after the client was written; misreading other_label presence as permission to submit other.","solutions":["Check question.allow_other before offering a free-text/other input","If the question disallows other, force selection of one of the defined options","Update the client to branch on allow_other from the current schema"],"exampleFix":"// before\nif (!matchesAnyOption) answer.kind = 'other';\n// after\nif (!matchesAnyOption && question.allow_other) answer.kind = 'other';\nelse if (!matchesAnyOption) throw new Error('must pick a listed option');","handlingStrategy":"type-guard","validationCode":"if (answer.kind === 'other' && !question.allow_other) throw new Error('other not allowed — pick an option');","typeGuard":"function allowsOther(q: NormalizedQuestionItem): boolean { return q.allow_other === true; }","tryCatchPattern":"try { await submit(p, answers); } catch (e) { if (/kind=other is not allowed/.test((e as Error).message)) { switchToOptionMode(); return; } throw e; }","preventionTips":["Only render a free-text input when question.allow_other is true","Re-read allow_other from the current schema, not a cached copy"],"tags":["validation","allow-other","answers"],"backgroundTag":"schema-validation-failed","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}