{"record":{"id":"467f0c30c7bde289","repo":"Yeachan-Heo/oh-my-codex","slug":"answers-entry-index-answer-other-text-must-be","errorCode":null,"errorMessage":"answers[${entry.index}].answer.other_text must be a non-empty string","messagePattern":"answers\\[(.+?)\\]\\.answer\\.other_text must be a non-empty string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/question/state.ts","lineNumber":372,"sourceCode":"  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    }\n    const selectedValue = selectedValues[0]!;\n    if (!optionValues.has(selectedValue)) {","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/question/state.ts#L354-L390","documentation":"An other-kind answer must carry other_text as a non-empty string (after trimming). This error fires when other_text is missing, empty, or whitespace-only.","triggerScenarios":"answer.kind === 'other' with other_text undefined, '', or '   '.","commonSituations":"Free-text input left blank but the UI still submitted; client not copying the typed text into other_text; trim producing empty from whitespace input.","solutions":["Require non-empty free-text input in the UI before enabling submit for other answers","Set answer.other_text = trimmed input and block submit if empty"],"exampleFix":"// before\nanswer.kind = 'other'; // other_text never set\n// after\nconst text = otherInput.trim();\nif (!text) return showError('Enter a value');\nanswer.kind = 'other'; answer.other_text = text; answer.selected_values = [text]; answer.value = text;","handlingStrategy":"validation","validationCode":"const text = (answer.other_text ?? '').trim();\nif (answer.kind === 'other' && !text) throw new Error('other text required');","typeGuard":"function hasOtherText(a: QuestionAnswerEntry): boolean { return typeof a.answer.other_text === 'string' && a.answer.other_text.trim().length > 0; }","tryCatchPattern":"try { await submit(p, answers); } catch (e) { if (/other_text must be a non-empty string/.test((e as Error).message)) { promptForOtherText(); return; } throw e; }","preventionTips":["Require non-empty free-text before enabling submit for other answers","Trim input at capture time"],"tags":["validation","allow-other","required-field"],"backgroundTag":"schema-validation-failed","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}