{"record":{"id":"94b993b78fc58e9e","repo":"nextauthjs/next-auth","slug":"no-user-found","errorCode":null,"errorMessage":"No user found.","messagePattern":"No user found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/adapter-drizzle/src/lib/mysql.ts","lineNumber":227,"sourceCode":"      } | null>\n    },\n    async updateUser(data: Partial<AdapterUser> & Pick<AdapterUser, \"id\">) {\n      if (!data.id) {\n        throw new Error(\"No user id.\")\n      }\n\n      await client\n        .update(usersTable)\n        .set(data)\n        .where(eq(usersTable.id, data.id))\n\n      const [result] = await client\n        .select()\n        .from(usersTable)\n        .where(eq(usersTable.id, data.id))\n\n      if (!result) {\n        throw new Error(\"No user found.\")\n      }\n\n      return result as Awaitable<AdapterUser>\n    },\n    async updateSession(\n      data: Partial<AdapterSession> & Pick<AdapterSession, \"sessionToken\">\n    ) {\n      await client\n        .update(sessionsTable)\n        .set(data)\n        .where(eq(sessionsTable.sessionToken, data.sessionToken))\n\n      return client\n        .select()\n        .from(sessionsTable)\n        .where(eq(sessionsTable.sessionToken, data.sessionToken))\n        .then((res) => res[0])\n    },","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/adapter-drizzle/src/lib/mysql.ts#L209-L245","documentation":"After performing the UPDATE, the adapter re-selects the user row by id; if no row comes back it throws 'No user found.' instead of returning undefined. This means the update targeted an id that does not exist in the users table.","triggerScenarios":"adapter.updateUser({ id, ... }) where no user with that id exists in the MySQL users table (stale/deleted id, wrong database, or id type mismatch).","commonSituations":"Updating a user that was deleted in another request, pointing the drizzle client at a different database/schema than the one holding users, or string-vs-number id coercion issues in MySQL.","solutions":["Verify the user exists first via getUser(id) before updating.","Confirm the drizzle client connects to the database/schema containing your users table.","Check the id value/type matches what is stored (avoid silent MySQL coercions).","Insert the user first if the flow expects createUser to have run."],"exampleFix":"// before\nawait adapter.updateUser({ id: staleId, name: 'new' })\n// after\nconst user = await adapter.getUser(staleId)\nif (!user) throw new Error(`User ${staleId} does not exist`)\nawait adapter.updateUser({ id: staleId, name: 'new' })","handlingStrategy":"validation","validationCode":"const user = await adapter.getUser(id)\nif (!user) throw new Error(`No user with id ${id} to update`)","typeGuard":"function isExistingUser(u: AdapterUser | null): u is AdapterUser {\n  return u !== null && typeof u.id === 'string'\n}","tryCatchPattern":"try {\n  const updated = await adapter.updateUser({ id, ...changes })\n} catch (e) {\n  if (e instanceof Error && e.message === 'No user found.') {\n    // the row vanished or id is wrong; handle as 404, not 500\n  }\n  throw e\n}","preventionTips":["Check existence with getUser(id) before updating","Use the same database connection for reads and writes","Avoid updating users based on stale cached ids","Watch for MySQL id type coercion (string vs number)"],"tags":["database","drizzle","mysql","record-not-found"],"backgroundTag":"record-not-found","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}