{"record":{"id":"1dab475c9964e5ad","repo":"paperclipai/paperclip","slug":"enter-a-nonempty-answer-within-the-task-s-length-limit","errorCode":null,"errorMessage":"Enter a nonempty answer within the task’s length limit","messagePattern":"Enter a nonempty answer within the task’s length limit","errorType":"validation","errorClass":"PhotonAnswerValidationError","httpStatus":null,"severity":"error","filePath":"server/src/services/photon/interactions.ts","lineNumber":90,"sourceCode":"    questionIndex: Number(match[3] ?? 1) - 1,\n    value: match[4]?.trim() ?? \"\",\n  };\n}\nexport function parsePhotonQuestionAnswer(\n  interaction: AskUserQuestionsInteraction,\n  questionIndex: number,\n  value: string,\n): AskUserQuestionsAnswer {\n  const question = interaction.payload.questions[questionIndex];\n  if (!question)\n    throw new PhotonAnswerValidationError(\"That question does not exist\");\n  if (value.toLowerCase() === \"skip\") {\n    if (question.required !== false)\n      throw new PhotonAnswerValidationError(\"This question requires an answer\");\n    return { questionId: question.id, optionIds: [] };\n  }\n  if (!value || value.length > 100_000)\n    throw new PhotonAnswerValidationError(\n      \"Enter a nonempty answer within the task’s length limit\",\n    );\n  const numbers =\n    /^\\d+(?:[ ,]+\\d+)*$/.test(value) &&\n    question.options.some((option) => !option.freeText)\n      ? value.split(/[ ,]+/).map(Number)\n      : null;\n  if (numbers) {\n    if (\n      new Set(numbers).size !== numbers.length ||\n      numbers.some((index) => index < 1 || index > question.options.length)\n    )\n      throw new PhotonAnswerValidationError(\n        \"Choose valid option numbers without duplicates\",\n      );\n    if (question.selectionMode === \"single\" && numbers.length !== 1)\n      throw new PhotonAnswerValidationError(\"Choose one option\");\n    if (numbers.some((index) => question.options[index - 1].freeText))","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/server/src/services/photon/interactions.ts#L72-L108","documentation":"PhotonAnswerValidationError thrown when the answer is empty or longer than 100,000 characters. parsePhotonQuestionAnswer enforces a nonempty, bounded-length answer for anything that is not a permitted \"skip\".","triggerScenarios":"Calling parsePhotonQuestionAnswer with value = \"\" or a string whose length exceeds 100000, for any non-skippable answer.","commonSituations":"An upstream agent submits an empty response when the user gave none; pasting a very large document (logs, dumps) as the answer; a null/undefined coerced to empty string before the call.","solutions":["Ensure the answer is nonempty and <= 100,000 characters before submitting","Truncate or summarize overly long input to fit the 100k limit","If the user genuinely wants to decline, use \"skip\" only on questions with required: false"],"exampleFix":"// before\nawait answer(interaction, index, userText);\n// after\nconst text = (userText ?? \"\").slice(0, 100_000);\nif (!text) return;\nawait answer(interaction, index, text);","handlingStrategy":"validation","validationCode":"const valid = typeof value === 'string' && value.length > 0 && value.length <= 100_000;","typeGuard":null,"tryCatchPattern":"try { return parsePhotonQuestionAnswer(interaction, i, value); } catch (e) { if (e instanceof PhotonAnswerValidationError && /nonempty/.test(e.message)) return truncateAndRetry(value.slice(0, 100_000)); throw e; }","preventionTips":["Clamp answer length to 100,000 characters before submitting","Reject empty strings in the UI before submission","Never pass null/undefined through to the parser"],"tags":["validation","payload-too-large","empty-input"],"backgroundTag":"payload-too-large","analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}