{"record":{"id":"1380224da1b6a3c6","repo":"nextauthjs/next-auth","slug":"missing-required-field-field-name","errorCode":null,"errorMessage":"Missing required field: ${field.name}","messagePattern":"Missing required field: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/lib/utils/webauthn-client.js","lineNumber":145,"sourceCode":"    // Start authentication\n    const authResp = await WebAuthnBrowser.startAuthentication(\n      options,\n      autofill\n    )\n\n    // Submit authentication response to server\n    return await submitForm(\"authenticate\", authResp)\n  }\n\n  /**\n   * @param {WebAuthnOptionsReturn<WebAuthnRegister>['options']} options\n   */\n  async function registrationFlow(options) {\n    // Check if all required formFields are set\n    const formFields = getFormFields()\n    formFields.forEach((field) => {\n      if (field.required && !field.value) {\n        throw new Error(`Missing required field: ${field.name}`)\n      }\n    })\n\n    // Start registration\n    const regResp = await WebAuthnBrowser.startRegistration(options)\n\n    // Submit registration response to server\n    return await submitForm(\"register\", regResp)\n  }\n\n  /**\n   * Attempts to authenticate the user when the page loads\n   * using the browser's autofill popup.\n   *\n   * @returns {Promise<void>}\n   */\n  async function autofillAuthentication() {\n    // if the browser can't handle autofill, don't try","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/core/src/lib/utils/webauthn-client.js#L127-L163","documentation":"registrationFlow validates that every required WebAuthn form field has a value before starting passkey registration with the browser. If any field marked required is empty or falsy, it throws immediately to stop an incomplete registration attempt from reaching the WebAuthn ceremony.","triggerScenarios":"Calling registrationFlow (typically from setupForm) when a required field such as username, email, or name has an empty value in the formFields returned by getFormFields().","commonSituations":"Users submitting the passkey setup form without filling required inputs; forms where autocomplete or prefills silently clear a field; custom forms that forget to bind a required input to the field value; language-specific field names that differ from the default.","solutions":["Validate the form in the UI and prevent submission until all required fields have values","Check getFormFields() output and ensure every required field is populated before calling registrationFlow","Mark fields as required:false if they genuinely are optional in your setup","Improve UX by surfacing which specific field failed (the field name is in the message)"],"exampleFix":"// before\nawait registrationFlow(options) // throws if required fields empty\n// after\nconst fields = getFormFields()\nconst missing = fields.filter(f => f.required && !f.value)\nif (missing.length === 0) {\n  await registrationFlow(options)\n} else {\n  setFieldErrors(missing.map(f => f.name))\n}","handlingStrategy":"validation","validationCode":"const missing = getFormFields().filter(f => f.required && !f.value)\nif (missing.length > 0) {\n  throw new Error(`Fill required fields: ${missing.map(f => f.name).join(\", \")}`)\n}\nawait registrationFlow(options)","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Add client-side HTML required attributes and JS validation before submit","Disable the submit button until all required fields have values","Surface per-field errors using the field name from the error message","Keep getFormFields() in sync with the rendered form inputs"],"tags":["webauthn","form-validation","input"],"backgroundTag":"missing-required-field","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}