{"record":{"id":"9f3f89058889c2f5","repo":"nextauthjs/next-auth","slug":"user-not-created","errorCode":null,"errorMessage":"User not created","messagePattern":"User not created","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/adapter-surrealdb/src/index.ts","lineNumber":196,"sourceCode":"\nexport function SurrealDBAdapter(\n  client: Promise<Surreal>\n  // options = {}\n): Adapter {\n  return {\n    async createUser(user: Partial<AdapterUser>) {\n      try {\n        const surreal = await client\n        const doc = userToDoc(user)\n        const userDoc = await surreal.create<UserDoc, Omit<UserDoc, \"id\">>(\n          \"user\",\n          doc\n        )\n        if (userDoc.length) {\n          return docToUser(userDoc[0])\n        }\n      } catch {}\n      throw new Error(\"User not created\")\n    },\n    async getUser(id: string) {\n      const surreal = await client\n      try {\n        const [userDoc] = await surreal.query<[UserDoc[]]>(\n          \"SELECT * FROM $user\",\n          {\n            user: new RecordId(\"user\", id),\n          }\n        )\n        const doc = userDoc.at(0)\n        if (doc) {\n          return docToUser(doc)\n        }\n      } catch {}\n      return null\n    },\n    async getUserByEmail(email: string) {","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/adapter-surrealdb/src/index.ts#L178-L214","documentation":"The SurrealDB adapter's createUser runs a CREATE query and, after first checking for an existing user by a uniqueness lookup, converts the returned documents via docToUser. If the query returns no documents (or the inner try/catch swallows a failure), it throws 'User not created' — meaning the database did not persist/return the new user row.","triggerScenarios":"CREATE silently failing (permission denied on the users table, schema constraint violation), the pre-check query throwing (caught by the empty catch block) followed by the fallthrough throw, wrong table name in the adapter config so inserts go nowhere visible, or SurrealDB connection returning empty results on error.","commonSituations":"Missing SurrealDB namespace/database selection so queries hit an empty scope; email already exists but the dedupe branch errored and was swallowed; SCHEMAFULL table definition rejecting the insert; auth/role misconfiguration preventing CREATE.","solutions":["Verify SurrealDB connection config includes correct namespace/database and the users table exists","Check SurrealDB permissions/roles allow CREATE on the users table","Inspect the swallowed exception in the dedupe lookup — log it to see the real failure (e.g., duplicate email)","If using SCHEMAFULL tables, ensure the insert matches the defined fields and types","Confirm the adapter query/mapping (table name, docToUser) matches your SurrealDB schema"],"exampleFix":"// before\ntry {\n  const [existing] = await surreal.query(\"SELECT * FROM user WHERE email = $email\", { email })\n} catch {}\nthrow new Error('User not created')\n// after\ntry {\n  const [existing] = await surreal.query(\"SELECT * FROM user WHERE email = $email\", { email })\n} catch (e) {\n  console.error('createUser pre-check failed', e)\n  throw e\n}","handlingStrategy":"validation","validationCode":"const surreal = await client\nconst [[info]] = await surreal.query(\"SELECT * FROM info()\")\nif (!info) throw new Error('SurrealDB namespace/database not selected')","typeGuard":"function isValidUserDoc(v: unknown): v is { id: string; email: string } {\n  return typeof v === 'object' && v !== null &&\n    typeof (v as any).email === 'string'\n}","tryCatchPattern":null,"preventionTips":["Verify namespace/database selection before app boot","Check table permissions allow CREATE","Align inserts with SCHEMAFULL field definitions"],"tags":["surrealdb","database","create","swallowed-exception","auth"],"backgroundTag":"insert-silently-failed","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}