{"record":{"id":"9c650ec287f7f8c5","repo":"nextauthjs/next-auth","slug":"user-not-updated","errorCode":null,"errorMessage":"User not updated","messagePattern":"User not updated","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/adapter-surrealdb/src/index.ts","lineNumber":264,"sourceCode":"        if (!user.id) throw new Error(\"User id is required\")\n        const surreal = await client\n        const doc: Partial<UserDoc> | null = removeUndefinedFields(\n          userToDoc({\n            ...user,\n            id: undefined,\n          })\n        )\n        if (doc) {\n          const updatedUser = await surreal.merge<UserDoc, Partial<UserDoc>>(\n            new RecordId(\"user\", user.id),\n            doc\n          )\n          if (updatedUser) {\n            return docToUser(updatedUser)\n          }\n        }\n      } catch {}\n      throw new Error(\"User not updated\")\n    },\n    async deleteUser(userId: string) {\n      const surreal = await client\n\n      // delete account\n      try {\n        const [accounts] = await surreal.query<[AccountDoc[]]>(\n          `SELECT * FROM account WHERE userId = $userId LIMIT 1`,\n          { userId: new RecordId(\"user\", userId) }\n        )\n        const account = accounts.at(0)\n        if (account) {\n          await surreal.delete(account.id)\n        }\n      } catch {}\n\n      // delete session\n      try {","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/adapter-surrealdb/src/index.ts#L246-L282","documentation":"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 {}`.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nawait adapter.updateUser({ id: maybeId, name })\n// after\nconst existing = await adapter.getUser(maybeId)\nif (!existing) throw new Error(`User ${maybeId} not found before update`)\nawait adapter.updateUser({ id: maybeId, name })","handlingStrategy":"try-catch","validationCode":"const existing = await adapter.getUser(user.id)\nif (!existing) throw new Error(`User ${user.id} does not exist`)\nawait adapter.updateUser(user)","typeGuard":null,"tryCatchPattern":"try {\n  return await adapter.updateUser(user)\n} catch (e) {\n  if (e.message === 'User not updated') {\n    console.error('updateUser failed; check SurrealDB connectivity/permissions', e)\n    throw e\n  }\n  throw e\n}","preventionTips":["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"],"tags":["adapter","surrealdb","update"],"backgroundTag":"adapter-write-failed","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}