paperclipai/paperclip · error · PhotonAnswerValidationError
Answer with the option number(s) shown in the prompt
Error message
Answer with the option number(s) shown in the prompt
What it means
PhotonAnswerValidationError thrown when the answer is free text but the question offers options, disallows free-form input (allowOther === false), and has no freeText option. In that case only option numbers are accepted.
Solutions
- Resubmit using the option number(s) shown in the prompt
- If free text should be allowed, set allowOther: true or add a freeText option and republish the prompt
- Update the UI to hide free-input controls when allowOther is false and options exist
Example fix
// before
await answer(interaction, index, "none of these");
// after
if (question.allowOther === false && question.options.length) {
await answer(interaction, index, "2");
} else {
await answer(interaction, index, "none of these");
} Defensive patterns
Strategy: validation
Validate before calling
const freeTextAllowed = question.allowOther !== false || question.options.some(o => o.freeText); if (question.options.length && !freeTextAllowed && !/^\d+([ ,]+\d+)*$/.test(value)) throw new Error('option numbers required'); Try / catch
try { return parsePhotonQuestionAnswer(interaction, i, value); } catch (e) { if (e instanceof PhotonAnswerValidationError && /option number/.test(e.message)) return forceOptionSelection(question); throw e; } Prevention
- Hide free-text inputs when allowOther === false and options exist
- Check allowOther and freeText presence before accepting prose answers
- Resurface the numbered prompt when the user submits disallowed text
When it happens
Trigger: Calling parsePhotonQuestionAnswer with a non-numeric value on a question that has options.length > 0, allowOther === false, and no option with freeText: true.
Common situations: User ignores the numbered choices and types prose into a strict multiple-choice question; a UI renders an input box for a question that should be option-only; allowOther was tightened to false after the UI rendered.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Choose one option
- Choose valid option numbers without duplicates
- Write your custom answer as text
- A full lowercase source SHA is required.
- A reusable lease cannot be replaced and reacquired in the…
AI-assisted analysis of paperclipai/paperclip@3f1d897a7c (2026-09-18).
Data as JSON: /api/errors/2ccb0fd5b4c82ce8.
Report an issue: GitHub.
Appendix: source
Thrown at server/src/services/photon/interactions.ts:117
if (
new Set(numbers).size !== numbers.length ||
numbers.some((index) => index < 1 || index > question.options.length)
)
throw new PhotonAnswerValidationError(
"Choose valid option numbers without duplicates",
);
if (question.selectionMode === "single" && numbers.length !== 1)
throw new PhotonAnswerValidationError("Choose one option");
if (numbers.some((index) => question.options[index - 1].freeText))
throw new PhotonAnswerValidationError("Write your custom answer as text");
return {
questionId: question.id,
optionIds: numbers.map((index) => question.options[index - 1].id),
};
}
const freeText = question.options.find((option) => option.freeText);
if (question.options.length && question.allowOther === false && !freeText)
throw new PhotonAnswerValidationError(
"Answer with the option number(s) shown in the prompt",
);
return {
questionId: question.id,
optionIds: freeText ? [freeText.id] : [],
otherText: value,
};
}
export function photonAnswersMatch(
interaction: AskUserQuestionsInteraction,
result: unknown,
): boolean {
if (!result || typeof result !== "object") return false;
const record = result as {
code?: unknown;
interactionId?: unknown;
answersSha256?: unknown;
};View on GitHub (pinned to 3f1d897a7c)