{"record":{"id":"5da50ac8b981aafe","repo":"nextauthjs/next-auth","slug":"user-not-found","errorCode":null,"errorMessage":"User not found.","messagePattern":"User not found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/adapter-drizzle/src/lib/sqlite.ts","lineNumber":204,"sourceCode":"      return result 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        .get()\n\n      if (!result) {\n        throw new Error(\"User not found.\")\n      }\n\n      return result as Awaitable<AdapterUser>\n    },\n    async updateSession(\n      data: Partial<AdapterSession> & Pick<AdapterSession, \"sessionToken\">\n    ) {\n      const result = await client\n        .update(sessionsTable)\n        .set(data)\n        .where(eq(sessionsTable.sessionToken, data.sessionToken))\n        .returning()\n        .get()\n\n      return result ?? null\n    },\n    async linkAccount(data: AdapterAccount) {\n      await client.insert(accountsTable).values(data).run()","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/adapter-drizzle/src/lib/sqlite.ts#L186-L222","documentation":"The SQLite Drizzle adapter's updateUser runs UPDATE ... WHERE id = ? RETURNING().get(). If .get() returns undefined, the WHERE clause matched no row, so the user with that id does not exist and the adapter throws 'User not found.'","triggerScenarios":"updateUser({ id: someId, ... }) where no row in the SQLite users table has that id — deleted user, wrong DB file, or id type mismatch (e.g. number vs string in SQLite).","commonSituations":"SQLite file path differences between environments (dev db vs test db) so the id exists in one but not the other; resetting the database file while holding stale session/user ids; SQLite flexible-mode type affinity causing '1' vs 1 id mismatches.","solutions":["Call getUser(id) first and only update when the user exists.","Confirm the Drizzle SQLite client uses the expected database file (check the db filename/connection per environment).","Ensure the id value's type matches how it was stored (consistent string uuids recommended).","If users are being deleted elsewhere, handle the not-found case in your flow instead of blindly updating."],"exampleFix":"// before\nawait adapter.updateUser({ id: staleId, name: 'New' })\n// after\nconst user = await adapter.getUser(staleId)\nif (!user) {\n  console.warn('User vanished, skipping update', staleId)\n  return\n}\nawait adapter.updateUser({ id: user.id, name: 'New' })","handlingStrategy":"validation","validationCode":"const existing = await adapter.getUser(id)\nif (!existing) throw new Error(`No SQLite user with id ${id}`)\nawait adapter.updateUser({ id, ...patch })","typeGuard":null,"tryCatchPattern":"try {\n  await adapter.updateUser({ id, ...patch })\n} catch (e) {\n  if ((e as Error).message === 'User not found.') {\n    console.warn(`User ${id} missing in SQLite; skipping update`)\n    return null\n  }\n  throw e\n}","preventionTips":["Confirm the Drizzle SQLite client file path matches the environment (dev/test/prod db files).","Use consistent id types (string uuids) to avoid SQLite type-affinity mismatch on eq().","Re-fetch users after any database reset or reseed instead of caching stale ids."],"tags":["database","drizzle","sqlite","not-found"],"backgroundTag":"record-not-found","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}