Yeachan-Heo/oh-my-codex · error

answers[${entry.index}].answer.other_text must be a non-empt

Error message

answers[${entry.index}].answer.other_text must be a non-empty string

What it means

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.

Source

Thrown at src/question/state.ts:372

  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]!;
    if (!optionValues.has(selectedValue)) {

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Require non-empty free-text input in the UI before enabling submit for other answers
  2. Set answer.other_text = trimmed input and block submit if empty

Example fix

// before
answer.kind = 'other'; // other_text never set
// after
const text = otherInput.trim();
if (!text) return showError('Enter a value');
answer.kind = 'other'; answer.other_text = text; answer.selected_values = [text]; answer.value = text;
Defensive patterns

Strategy: validation

Validate before calling

const text = (answer.other_text ?? '').trim();
if (answer.kind === 'other' && !text) throw new Error('other text required');

Type guard

function hasOtherText(a: QuestionAnswerEntry): boolean { return typeof a.answer.other_text === 'string' && a.answer.other_text.trim().length > 0; }

Try / catch

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

Prevention

When it happens

Trigger: answer.kind === 'other' with other_text undefined, '', or ' '.

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

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/467f0c30c7bde289. Report an issue: GitHub.