{"record":{"id":"286c465c5aa8cb20","repo":"nextauthjs/next-auth","slug":"unable-to-update-authenticator-with-credential-c","errorCode":null,"errorMessage":"Unable to update authenticator with credential ${credentialId}","messagePattern":"Unable to update authenticator with credential (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-surrealdb/src/index.ts","lineNumber":552,"sourceCode":"    async updateAuthenticatorCounter(\n      credentialId: AdapterAuthenticator[\"credentialID\"],\n      newCounter: AdapterAuthenticator[\"counter\"]\n    ) {\n      try {\n        if (!credentialId) throw new Error(\"credential id is required\")\n        const surreal = await client\n        const [authenticatorDoc] = await surreal.query<[AuthenticatorDoc]>(\n          `UPDATE ONLY authenticator MERGE $doc WHERE credentialID = $cid`,\n          {\n            cid: credentialId,\n            doc: {\n              counter: newCounter,\n            },\n          }\n        )\n        return docToAuthenticator(authenticatorDoc)\n      } catch {}\n      throw Error(\n        `Unable to update authenticator with credential ${credentialId}`\n      )\n    },\n  }\n}\n","sourceCodeStart":534,"sourceCodeEnd":558,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/adapter-surrealdb/src/index.ts#L534-L558","documentation":"The SurrealDB adapter's updateAuthenticator attempts to patch the authenticator record for the given credentialId; any failure (record not found, query error, mapper error) is swallowed by an empty catch and rethrown as this generic Error. It means the WebAuthn authenticator could not be persisted for that credential.","triggerScenarios":"Calling SurrealDBAdapter's updateAuthenticator (invoked via the WebAuthn config flow) when the authenticator row for credentialId does not exist, the credentials table name/structure differs from what the adapter expects, or the SurrealDB UPDATE query fails (permissions, connection).","commonSituations":"WebAuthn credentials stored by another adapter/version with a different schema; SurrealDB table permissions (DEFINE TABLE ... PERMISSIONS) blocking updates; credentialId casing/format mismatch; SurrealDB instance migration leaving stale authenticator records.","solutions":["Verify the authenticator record exists in SurrealDB: SELECT * FROM authenticators WHERE credentialId = '...'","Add logging inside the swallowed catch (or temporarily rethrow) to see the real underlying SurrealDB error","Check table permissions allow UPDATE for the adapter's user/role","Ensure the SurrealDB schema matches the adapter's expected authenticators table (counter, credentialPublicKey, credentialDeviceType, etc.)"],"exampleFix":"// before\n} catch {}\nthrow Error(`Unable to update authenticator with credential ${credentialId}`)\n// after\n} catch (e) {\n  console.error(`updateAuthenticator failed for ${credentialId}`, e)\n  throw e\n}","handlingStrategy":"try-catch","validationCode":"const existing = await surreal.query(\n  `SELECT * FROM authenticators WHERE credentialId = $id`, { id: credentialId }\n)\nif (!existing[0]?.result?.length) throw new Error(`Authenticator ${credentialId} not found`)","typeGuard":"function isAuthenticatorDoc(d: unknown): d is { credentialId: string; counter: number } {\n  return typeof d === 'object' && d !== null && 'credentialId' in d\n}","tryCatchPattern":"try {\n  await updateAuthenticator(authenticator)\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Unable to update authenticator')) {\n    // inspect SurrealDB permissions/schema, then retry or re-register credential\n  }\n  throw e\n}","preventionTips":["Keep SurrealDB table permissions open to the adapter's connection user","Maintain the exact authenticators schema the adapter expects","Never swallow the underlying catch — patch the adapter or wrap it with logging","Validate credentials were written by the same adapter version that reads them"],"tags":["webauthn","surrealdb","adapter","database"],"backgroundTag":"adapter-update-authenticator-failed","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}