{"record":{"id":"8cd133046c649ef6","repo":"nextauthjs/next-auth","slug":"no-user-found-8cd133","errorCode":null,"errorMessage":"No user found.","messagePattern":"No user found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/adapter-drizzle/src/lib/pg.ts","lineNumber":203,"sourceCode":"        .innerJoin(usersTable, eq(usersTable.id, sessionsTable.userId))\n        .then((res) => (res.length > 0 ? res[0] : null)) as Awaitable<{\n        session: AdapterSession\n        user: AdapterUser\n      } | 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      const [result] = await client\n        .update(usersTable)\n        .set(data)\n        .where(eq(usersTable.id, data.id))\n        .returning()\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      return client\n        .update(sessionsTable)\n        .set(data)\n        .where(eq(sessionsTable.sessionToken, data.sessionToken))\n        .returning()\n        .then((res) => res[0])\n    },\n    async linkAccount(data: AdapterAccount) {\n      await client.insert(accountsTable).values(data)\n    },\n    async getUserByAccount(","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/adapter-drizzle/src/lib/pg.ts#L185-L221","documentation":"After issuing UPDATE ... WHERE id = ? RETURNING on the users table, the Drizzle pg adapter checks the returned row. If no row came back, the UPDATE matched zero rows — meaning no user with that id exists — and the adapter throws 'No user found.' rather than silently returning undefined.","triggerScenarios":"Calling updateUser({ id: '<nonexistent-id>' , ...changes }) where the id is not present in the users table (row deleted concurrently, wrong database, stale id from a client).","commonSituations":"Stale ids held in a client after the user was deleted in another session; pointing the adapter at a different database/env than the one that created the user; soft-delete setups that remove rows the adapter still expects; id type mismatches (string uuid vs integer) that silently match nothing.","solutions":["Verify the user with getUser(id) exists before calling updateUser.","Confirm the adapter's Drizzle client points at the same database/schema where the user row lives (check connection string per environment).","Check whether the row was deleted by another process/job; refresh the id from the source of truth.","Inspect the usersTable schema mapping to make sure eq(usersTable.id, data.id) compares the right column/type."],"exampleFix":"// before\nawait adapter.updateUser({ id: maybeId, email: newEmail })\n// after\nconst user = await adapter.getUser(maybeId)\nif (!user) throw new Error(`User ${maybeId} does not exist`)\nawait adapter.updateUser({ id: user.id, email: newEmail })","handlingStrategy":"validation","validationCode":"const existing = await adapter.getUser(id)\nif (!existing) throw new Error(`Cannot update: no user with id ${id}`)\nawait adapter.updateUser({ id, ...patch })","typeGuard":"function isExistingUser(u: AdapterUser | null): u is AdapterUser {\n  return u !== null && typeof u.id === 'string'\n}","tryCatchPattern":"try {\n  await adapter.updateUser({ id, ...patch })\n} catch (e) {\n  if ((e as Error).message === 'No user found.') {\n    console.warn(`User ${id} not found; skipping update`)\n    return null\n  }\n  throw e\n}","preventionTips":["Read-before-write: call getUser(id) and bail out when null.","Keep ids in sync across environments; never hardcode ids from another database.","Watch for concurrent delete jobs that may remove users between read and update."],"tags":["database","drizzle","postgresql","not-found"],"backgroundTag":"record-not-found","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}