{"record":{"id":"b35180f03a8ed60a","repo":"nextauthjs/next-auth","slug":"no-user-id-b35180","errorCode":null,"errorMessage":"No user id.","messagePattern":"No user id\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/adapter-drizzle/src/lib/pg.ts","lineNumber":193,"sourceCode":"        .then((res) => res[0])\n    },\n    async getSessionAndUser(sessionToken: string) {\n      return client\n        .select({\n          session: sessionsTable,\n          user: usersTable,\n        })\n        .from(sessionsTable)\n        .where(eq(sessionsTable.sessionToken, sessionToken))\n        .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","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/adapter-drizzle/src/lib/pg.ts#L175-L211","documentation":"The Drizzle PostgreSQL adapter's updateUser requires a user id to build its WHERE clause. If the AdapterUser passed in has no id (falsy/undefined), the adapter refuses to issue an UPDATE that would otherwise match every row, and throws this error instead. It is a defensive input-validation guard inside packages/adapter-drizzle/src/lib/pg.ts updateUser.","triggerScenarios":"Calling updateUser({}) or updateUser({ name: 'x' }) without an id property, or with id: undefined / id: '' — typically from a custom flow that builds the partial user manually instead of receiving it from Auth.js.","commonSituations":"Custom user-migration or admin scripts that construct AdapterUser objects by hand; spreading an object whose id field was renamed (e.g. userId instead of id); typing the argument loosely as Partial<AdapterUser> so TS doesn't catch the missing id at compile time.","solutions":["Ensure the object passed to updateUser includes a valid id: updateUser({ id: user.id, name: 'New Name' }).","Check that the user object originates from getUser/getUserByAccount/getUserByEmail so the id is populated by the adapter.","Add an early check in your code: if (!user.id) throw new Error('id required') before calling updateUser.","If id exists but is falsy at runtime, verify your custom users table id column mapping in the Drizzle schema (e.g. uuid default)."],"exampleFix":"// before\nawait adapter.updateUser({ name: 'Alice' })\n// after\nawait adapter.updateUser({ id: existingUser.id, name: 'Alice' })","handlingStrategy":"validation","validationCode":"if (!user || !user.id) throw new Error('updateUser requires a valid user.id')\nawait adapter.updateUser({ id: user.id, ...patch })","typeGuard":"function hasId(u: Partial<AdapterUser> | undefined | null): u is AdapterUser & { id: string } {\n  return typeof u?.id === 'string' && u.id.length > 0\n}","tryCatchPattern":"try {\n  await adapter.updateUser(patch)\n} catch (e) {\n  if ((e as Error).message === 'No user id.') {\n    throw new Error('Caller bug: user id missing before updateUser')\n  }\n  throw e\n}","preventionTips":["Always source user objects from adapter getters (getUser/getUserByEmail) so id is populated.","Type update payloads as AdapterUser & Partial<AdapterUser> rather than Partial<AdapterUser> alone.","Add a runtime assertion helper for ids before any adapter write."],"tags":["input-validation","database","drizzle","postgresql"],"backgroundTag":"missing-entity-id","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}