nextauthjs/next-auth · error
User not updated
Error message
User not updated
What it means
This is a catch-all failure in updateUser(): the try block swallows any underlying error (SurrealDB connection failure, query error, empty result), and if no updated document comes back the adapter throws a generic 'User not updated'. The real cause is hidden by the empty `catch {}`.
Source
Thrown at packages/adapter-surrealdb/src/index.ts:264
if (!user.id) throw new Error("User id is required")
const surreal = await client
const doc: Partial<UserDoc> | null = removeUndefinedFields(
userToDoc({
...user,
id: undefined,
})
)
if (doc) {
const updatedUser = await surreal.merge<UserDoc, Partial<UserDoc>>(
new RecordId("user", user.id),
doc
)
if (updatedUser) {
return docToUser(updatedUser)
}
}
} catch {}
throw new Error("User not updated")
},
async deleteUser(userId: string) {
const surreal = await client
// delete account
try {
const [accounts] = await surreal.query<[AccountDoc[]]>(
`SELECT * FROM account WHERE userId = $userId LIMIT 1`,
{ userId: new RecordId("user", userId) }
)
const account = accounts.at(0)
if (account) {
await surreal.delete(account.id)
}
} catch {}
// delete session
try {View on GitHub (pinned to a1a16a5a77)
Solutions
- Verify the user with that id actually exists (getUser) before updating
- Temporarily log inside the try block or run the SurrealDB query manually to surface the swallowed underlying error
- Check SurrealDB connection settings (endpoint, namespace, database, auth) in the adapter config/env
- Confirm the id format matches how the adapter stores doc ids
Example fix
// before
await adapter.updateUser({ id: maybeId, name })
// after
const existing = await adapter.getUser(maybeId)
if (!existing) throw new Error(`User ${maybeId} not found before update`)
await adapter.updateUser({ id: maybeId, name }) Defensive patterns
Strategy: try-catch
Validate before calling
const existing = await adapter.getUser(user.id)
if (!existing) throw new Error(`User ${user.id} does not exist`)
await adapter.updateUser(user) Try / catch
try {
return await adapter.updateUser(user)
} catch (e) {
if (e.message === 'User not updated') {
console.error('updateUser failed; check SurrealDB connectivity/permissions', e)
throw e
}
throw e
} Prevention
- Verify SurrealDB env vars (endpoint, ns, db, credentials) before deploying
- Ensure the user table exists and the adapter role has UPDATE permission
- Check user existence before updating; wrap adapter calls in error logging
When it happens
Trigger: SurrealDB client connection rejected; the UPDATE/MERGE query for the user document failed or returned nothing; the user id does not correspond to an existing user document; docToUser threw on malformed data — all funneled into this single throw.
Common situations: Updating a user whose record was deleted; SurrealDB namespace/database misconfigured in env vars; network/permission errors against SurrealDB being masked as this generic message; id mismatch between adapter user ids and stored doc ids.
Related errors
- User id is required
- Account not created
- Verification Token not created
- Verification Token not used
- Authenticator not created
AI-assisted analysis of nextauthjs/next-auth@a1a16a5a77 (2026-08-28).
Data as JSON: /api/errors/9c650ec287f7f8c5.
Report an issue: GitHub.