{"record":{"id":"dcc8bd87e3d729e4","repo":"nextauthjs/next-auth","slug":"verification-token-not-used","errorCode":null,"errorMessage":"Verification Token not used","messagePattern":"Verification Token not used","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/adapter-surrealdb/src/index.ts","lineNumber":471,"sourceCode":"        const [tokens] = await surreal.query<[VerificationTokenDoc[]]>(\n          `SELECT * FROM verification_token WHERE identifier = $identifier AND token = $vt LIMIT 1`,\n          { identifier, vt: token }\n        )\n        if (tokens.length && tokens.at(0)) {\n          const vt = tokens[0]\n          if (vt) {\n            await surreal.delete(vt.id)\n            const verificationTokenDoc: Partial<VerificationTokenDoc> = vt\n            if (verificationTokenDoc.id) delete verificationTokenDoc.id\n            return docToVerificationToken(\n              verificationTokenDoc as VerificationTokenDoc\n            )\n          }\n        } else {\n          return null\n        }\n      } catch {}\n      throw new Error(\"Verification Token not used\")\n    },\n    async getAccount(\n      providerAccountId: AdapterAccount[\"providerAccountId\"],\n      provider: AdapterAccount[\"provider\"]\n    ) {\n      const surreal = await client\n      try {\n        const [accountsDoc] = await surreal.query<[AccountDoc[]]>(\n          `SELECT * FROM account WHERE providerAccountId = $pid AND provider = $provider LIMIT 1`,\n          {\n            pid: providerAccountId,\n            provider,\n          }\n        )\n        if (accountsDoc.length) {\n          return docToAccount(accountsDoc[0])\n        }\n      } catch {}","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/adapter-surrealdb/src/index.ts#L453-L489","documentation":"useVerificationToken() consumes (reads and deletes) a verification token during sign-in. If anything in the try block throws — connection error, query failure, unexpected doc shape — the empty catch converts it into 'Verification Token not used'. A genuinely absent token returns null instead, so this error usually means an operation failed rather than a missing token.","triggerScenarios":"SurrealDB transaction/query for fetching+deleting the token threw; the returned doc could not be converted by docToVerificationToken; database unreachable at sign-in time.","commonSituations":"User clicks a magic link while the DB is briefly unavailable; schema change made the stored doc incompatible with VerificationTokenDoc; permissions deny DELETE on the token table.","solutions":["Retry the sign-in flow; if intermittent, check SurrealDB availability/logs at that moment","Verify the stored token doc matches the expected VerificationTokenDoc shape (identifier, token, expires)","Check SurrealDB permissions allow SELECT and DELETE on the token table","Add logging in the try block to surface the swallowed error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const token = await adapter.useVerificationToken({ identifier, token })\n  if (token === null) {\n    // genuinely missing/expired token — show 'invalid link' UI\n  }\n  return token\n} catch (e) {\n  // 'Verification Token not used' => DB/query failure, not a bad token\n  console.error('useVerificationToken DB failure', e)\n  throw e\n}","preventionTips":["Distinguish null (bad token) from thrown error (DB failure) in UX flows","Grant SELECT/DELETE permissions on the token table","Keep VerificationTokenDoc schema stable to avoid docToVerificationToken failures"],"tags":["adapter","verification-token","surrealdb"],"backgroundTag":"adapter-write-failed","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}