{"record":{"id":"4bef957a035cc217","repo":"paperclipai/paperclip","slug":"unsupported-discord-correction-field","errorCode":null,"errorMessage":"Unsupported Discord correction field","messagePattern":"Unsupported Discord correction field","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/src/services/chat-discord-question-forms.ts","lineNumber":170,"sourceCode":"      now.getTime() + CORRECTION_TTL_MS,\n    ),\n  );\n  if (\n    !Number.isFinite(expiresAt.getTime()) ||\n    expiresAt <= now ||\n    input.modal.callbackId !== input.submitActionId ||\n    input.modal.privateMetadata !== input.submitActionId ||\n    input.modal.children.length < 1 ||\n    input.modal.children.length > 5\n  )\n    throw new Error(\"Discord form correction is not current\");\n  const values: Record<string, string> = {};\n  const messages: string[] = [\n    \"Please check your answers, then select Edit answers.\",\n  ];\n  for (const child of input.modal.children) {\n    if (child.type !== \"text_input\" && child.type !== \"select\")\n      throw new Error(\"Unsupported Discord correction field\");\n    const value = input.values[child.id];\n    const error = input.fieldErrors[child.id];\n    // Both label and error are produced by canonical form validation, never\n    // provider labels/error bodies. Opaque input IDs are not visible copy.\n    if (error) messages.push(`${child.label}: ${error}`);\n    if (typeof value !== \"string\") continue;\n    if (child.type === \"text_input\") {\n      const maximum = Math.min(child.maxLength ?? 4000, 4000);\n      values[child.id] = value.slice(0, maximum);\n      if (value.length > maximum)\n        messages.push(\n          `${child.label}: This draft was shortened to ${maximum} characters.`,\n        );\n    } else if (child.options.some((option) => option.value === value))\n      values[child.id] = value;\n  }\n  const {\n    modal: _modal,","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/chat-discord-question-forms.ts#L152-L188","documentation":"While collecting modal values into a correction draft, each modal child must be a supported input type (text_input or select). This error is thrown when a modal child has an unrecognized or unsupported component type, so the correction draft cannot be built faithfully from the submitted values.","triggerScenarios":"A modal contains a component whose type is neither 'text_input' nor 'select' (e.g. a newer Discord component kind, or a malformed custom-built child); the modal schema was extended elsewhere without updating this retention path.","commonSituations":"A developer adds a new modal component type (e.g. a new Discord input variant) to the form builder but forgets to support it in retainDiscordQuestionFormCorrection; a Discord API update introduces new component types.","solutions":["Inspect the modal children and remove or replace any unsupported component type before submission","Extend the handler to explicitly support the new child type and map its value","Check for library/package updates that changed Discord component type names"],"exampleFix":"// before\nif (child.type !== \"text_input\" && child.type !== \"select\")\n  throw new Error(\"Unsupported Discord correction field\");\n// after\nif (child.type === \"text_input\" || child.type === \"select\" || child.type === \"new_component\") {\n  // handle child\n} else {\n  throw new Error(\"Unsupported Discord correction field\");\n}","handlingStrategy":"type-guard","validationCode":"function allChildrenSupported(children) {\n  return children.every((c) => c.type === \"text_input\" || c.type === \"select\");\n}\nif (!allChildrenSupported(modal.children)) throw new Error(\"build modal with supported field types only\");","typeGuard":"const isSupportedChild = (c) => c && (c.type === \"text_input\" || c.type === \"select\");","tryCatchPattern":"try {\n  await retainDiscordQuestionFormCorrection(...);\n} catch (err) {\n  if (err.message === \"Unsupported Discord correction field\") {\n    // rebuild modal with supported types\n    return respondWithRebuiltForm();\n  }\n  throw err;\n}","preventionTips":["Only construct modals from the whitelisted component types in the form builder","Add a unit test that every modal the builder emits passes the child-type check","When Discord adds component types, update both builder and retention paths together"],"tags":["discord","validation","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}