Yeachan-Heo/oh-my-codex · error

answers[${entry.index}].answer.kind=other is not allowed for

Error message

answers[${entry.index}].answer.kind=other is not allowed for this question

What it means

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.

Source

Thrown at src/question/state.ts:370

    };
  }
  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`);
    }

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Check question.allow_other before offering a free-text/other input
  2. If the question disallows other, force selection of one of the defined options
  3. Update the client to branch on allow_other from the current schema

Example fix

// before
if (!matchesAnyOption) answer.kind = 'other';
// after
if (!matchesAnyOption && question.allow_other) answer.kind = 'other';
else if (!matchesAnyOption) throw new Error('must pick a listed option');
Defensive patterns

Strategy: type-guard

Validate before calling

if (answer.kind === 'other' && !question.allow_other) throw new Error('other not allowed — pick an option');

Type guard

function allowsOther(q: NormalizedQuestionItem): boolean { return q.allow_other === true; }

Try / catch

try { await submit(p, answers); } catch (e) { if (/kind=other is not allowed/.test((e as Error).message)) { switchToOptionMode(); return; } throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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/25bf86079b91a29a. Report an issue: GitHub.