Yeachan-Heo/oh-my-codex · error

answers[${entry.index}].answer.kind=other is only valid for

Error message

answers[${entry.index}].answer.kind=other is only valid for single-answerable questions

What it means

kind 'other' is defined only for single-answerable questions. Submitting it for a multi-answerable question (multi_select) is rejected because multi answers with out-of-schema values are handled differently (values mixed with option values, not via kind).

Source

Thrown at src/question/state.ts:371

  }
  throw new Error(`answers[${entry.index}].question_id is unknown for this question: ${entry.question_id}`);
}

function validateAnswerAgainstQuestion(question: NormalizedQuestionItem, entry: QuestionAnswerEntry): void {
  const { answer } = entry;
  const selectedValues = validateStringArray(answer.selected_values, `answers[${entry.index}].answer.selected_values`);
  const selectedLabels = validateStringArray(answer.selected_labels, `answers[${entry.index}].answer.selected_labels`);
  assertNoDuplicateValues(selectedValues, `answers[${entry.index}].answer.selected_values`);

  const optionValues = new Set(question.options.map((option) => option.value));
  const multi = isMultiAnswerableQuestion(question);
  const hasOtherText = typeof answer.other_text === 'string' && answer.other_text.trim().length > 0;
  const otherText = hasOtherText ? answer.other_text!.trim() : undefined;
  const outOfSchemaValues = selectedValues.filter((value) => !optionValues.has(value));

  if (answer.kind === 'other') {
    if (!question.allow_other) throw new Error(`answers[${entry.index}].answer.kind=other is not allowed for this question`);
    if (multi) throw new Error(`answers[${entry.index}].answer.kind=other is only valid for single-answerable questions`);
    if (!otherText) throw new Error(`answers[${entry.index}].answer.other_text must be a non-empty string`);
    if (selectedValues.length !== 1 || selectedValues[0] !== otherText || answer.value !== otherText) {
      throw new Error(`answers[${entry.index}].answer other value must match selected_values[0] and other_text`);
    }
    assertSelectedLabelsMatch(
      selectedLabels,
      [question.other_label],
      `answers[${entry.index}].answer.selected_labels`,
    );
    return;
  }

  if (answer.kind === 'option') {
    if (multi) throw new Error(`answers[${entry.index}].answer.kind=option is only valid for single-answerable questions`);
    if (selectedValues.length !== 1 || selectedLabels.length !== 1) {
      throw new Error(`answers[${entry.index}].answer must select exactly one option`);
    }
    const selectedValue = selectedValues[0]!;

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. For multi questions, include the free-text value inside selected_values (with other_text set) instead of using kind 'other'
  2. Branch submit logic on question.multi_select

Example fix

// before
if (freeText) answer.kind = 'other';
// after
if (freeText && question.multi_select) { answer.kind = 'multi'; answer.selected_values = [...picked, freeText]; answer.other_text = freeText; }
else if (freeText) answer.kind = 'other';
Defensive patterns

Strategy: type-guard

Validate before calling

if (answer.kind === 'other' && isMulti(question)) throw new Error('use kind=multi with other_text for multi questions');

Type guard

function isMulti(q: NormalizedQuestionItem): boolean { return !!q.multi_select; }

Try / catch

try { await submit(p, answers); } catch (e) { if (/kind=other is only valid for single-answerable/.test((e as Error).message)) { convertOtherToMultiWithOtherText(answer); return submit(p, answers); } throw e; }

Prevention

When it happens

Trigger: answer.kind === 'other' on a question where isMultiAnswerableQuestion(question) is true (multi_select set).

Common situations: Shared client submit path that always uses kind 'other' for free text regardless of question type; schema flipped from single to multi_select.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/6e01569cd536042b. Report an issue: GitHub.