Yeachan-Heo/oh-my-codex · error
answers[${entry.index}].answer other value must match select
Error message
answers[${entry.index}].answer other value must match selected_values[0] and other_text What it means
For other-kind answers, consistency is enforced: selected_values must have exactly one element equal to the trimmed other_text, and answer.value must equal it too. Any divergence throws this error.
Source
Thrown at src/question/state.ts:374
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)) {
throw new Error(`answers[${entry.index}].answer selected value is not in the option schema: ${selectedValue}`);
}View on GitHub (pinned to 3ad79a8a6f)
Solutions
- Set all three fields from one source: const text = input.trim(); value = text; selected_values = [text]; other_text = text
- Never use a sentinel like '__other__' as the value; the free text itself is the value
Example fix
// before answer.value = '__other__'; answer.selected_values = ['__other__']; answer.other_text = text; // after const t = text.trim(); answer.value = t; answer.selected_values = [t]; answer.other_text = t;
Defensive patterns
Strategy: validation
Validate before calling
const t = (answer.other_text ?? '').trim();
if (answer.kind === 'other' && (answer.selected_values.length !== 1 || answer.selected_values[0] !== t || answer.value !== t)) {
answer.value = t; answer.selected_values = [t];
} Type guard
function otherAnswerConsistent(a: QuestionAnswerEntry): boolean {
const t = typeof a.answer.other_text === 'string' ? a.answer.other_text.trim() : '';
return t.length > 0 && a.answer.selected_values.length === 1 && a.answer.selected_values[0] === t && a.answer.value === t;
} Try / catch
try { await submit(p, answers); } catch (e) { if (/other value must match/.test((e as Error).message)) { syncOtherFieldsFromOtherText(answer); return submit(p, answers); } throw e; } Prevention
- Populate value, selected_values and other_text from one trimmed string
- Avoid sentinel values like '__other__'
When it happens
Trigger: kind 'other' where selected_values[0] !== other_text.trim(), selected_values.length !== 1, or answer.value !== other_text — e.g. sending the matched option value while other_text holds the free text.
Common situations: Client setting value/selected_values from a hidden 'other' option value (like '__other__') while other_text holds real text; partial normalization that trims one field but not the 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
- answers[${entry.index}].answer.kind=other is not allowed for
- answers[${entry.index}].answer.kind=other is only valid for
- answers[${entry.index}].answer.other_text must be a non-empt
- invalid auth slot path
- Autoresearch goal ${mission.slug} cannot complete until prof
AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27).
Data as JSON: /api/errors/0416658d6912934d.
Report an issue: GitHub.