nextauthjs/next-auth · error
No user id.
Error message
No user id.
What it means
Same guard as its PostgreSQL sibling but in the SQLite Drizzle adapter: updateUser requires a truthy id before it can build the WHERE clause. A missing id would make the UPDATE ambiguous or match all rows, so the adapter throws 'No user id.' immediately.
Source
Thrown at packages/adapter-drizzle/src/lib/sqlite.ts:193
const result =
(await client
.select({
session: sessionsTable,
user: usersTable,
})
.from(sessionsTable)
.where(eq(sessionsTable.sessionToken, sessionToken))
.innerJoin(usersTable, eq(usersTable.id, sessionsTable.userId))
.get()) ?? null
return result as Awaitable<{
session: AdapterSession
user: AdapterUser
} | null>
},
async updateUser(data: Partial<AdapterUser> & Pick<AdapterUser, "id">) {
if (!data.id) {
throw new Error("No user id.")
}
const result = await client
.update(usersTable)
.set(data)
.where(eq(usersTable.id, data.id))
.returning()
.get()
if (!result) {
throw new Error("User not found.")
}
return result as Awaitable<AdapterUser>
},
async updateSession(
data: Partial<AdapterSession> & Pick<AdapterSession, "sessionToken">
) {View on GitHub (pinned to a1a16a5a77)
Solutions
- Pass the id explicitly: updateUser({ id: user.id, ...changes }).
- Log/inspect the user object right before the call to confirm id is present and truthy.
- Make sure the user came from an adapter query (getUser, getUserByEmail) so id is set from the row.
- Check the usersTable id column mapping and type in the Drizzle SQLite schema.
Example fix
// before
const { id: _ignored, ...patch } = payload
await adapter.updateUser(patch)
// after
await adapter.updateUser({ id: payload.id, ...payload.changes }) Defensive patterns
Strategy: validation
Validate before calling
if (!user?.id) throw new Error('updateUser requires a valid user.id')
await adapter.updateUser({ id: user.id, ...patch }) Type guard
function hasUserId(u: unknown): u is AdapterUser {
return typeof u === 'object' && u !== null &&
typeof (u as AdapterUser).id === 'string' && (u as AdapterUser).id.length > 0
} Try / catch
try {
await adapter.updateUser(patch)
} catch (e) {
if ((e as Error).message === 'No user id.') {
console.error('updateUser called without id; payload:', patch)
return
}
throw e
} Prevention
- Never destructure-and-drop id from user payloads before updating.
- Seed SQLite dev databases through the adapter (createUser) so ids follow the expected format.
- Run a typecheck with a required-id payload type instead of loose Partial<AdapterUser>.
When it happens
Trigger: Calling updateUser with an object lacking id, id: undefined, or id: '' — commonly from hand-built AdapterUser objects or a destructuring bug that drops the id field.
Common situations: SQLite dev setups where user rows are seeded manually without ids; custom sign-in flows that pass a partial user; renaming the primary key column in the Drizzle schema so data.id is no longer populated from DB results.
Related errors
AI-assisted analysis of nextauthjs/next-auth@a1a16a5a77 (2026-08-28).
Data as JSON: /api/errors/7cd623e22e32a590.
Report an issue: GitHub.