Yeachan-Heo/oh-my-codex · error
answers[${entry.index}].answer.kind=option is only valid for
Error message
answers[${entry.index}].answer.kind=option is only valid for single-answerable questions What it means
Answers with kind 'option' represent a single choice and are only valid for single-answerable questions. Submitting kind 'option' to a multi-answerable (multi_select) question throws, because multi questions must use kind 'multi'.
Source
Thrown at src/question/state.ts:385
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}`);
}
if (answer.value !== selectedValue) {
throw new Error(`answers[${entry.index}].answer.value must match selected_values[0]`);
}
assertSelectedLabelsMatch(
selectedLabels,
expectedSelectedLabelsForValues(question, selectedValues, undefined),
`answers[${entry.index}].answer.selected_labels`,
);
return;
}
View on GitHub (pinned to 3ad79a8a6f)
Solutions
- Use kind 'multi' with array value/selected_values for multi_select questions
- Branch answer.kind on question.multi_select
Example fix
// before
answer.kind = 'option'; answer.value = v; answer.selected_values = [v];
// after
if (question.multi_select) { answer.kind = 'multi'; answer.value = vals; answer.selected_values = vals; }
else { answer.kind = 'option'; answer.value = v; answer.selected_values = [v]; } Defensive patterns
Strategy: type-guard
Validate before calling
if (answer.kind === 'option' && isMulti(question)) throw new Error('multi question requires kind=multi'); Type guard
function isMulti(q: NormalizedQuestionItem): boolean { return !!q.multi_select; } Try / catch
try { await submit(p, answers); } catch (e) { if (/kind=option is only valid for single-answerable/.test((e as Error).message)) { convertToMulti(answer); return submit(p, answers); } throw e; } Prevention
- Choose answer.kind from question.multi_select in a single builder function
- Rebuild the answer whenever the question type changes
When it happens
Trigger: answer.kind === 'option' while isMultiAnswerableQuestion(question) is true.
Common situations: Client defaulting to kind 'option' for every selection; question schema changed to multi_select after client written; single-select component reused for a multi question.
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
- ${path} must be a non-empty string array
- ${path} must not contain duplicate values: ${value}
- selected value is not in the option schema: ${value}
- ${path} cardinality must match selected values
- ${path}[${mismatchIndex}] must match the selected value labe
AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27).
Data as JSON: /api/errors/56763e5340a1acf4.
Report an issue: GitHub.