{"record":{"id":"0eb4715d5b83c158","repo":"mastra-ai/mastra","slug":"failed-to-create-account-0eb471","errorCode":null,"errorMessage":"Failed to create account","messagePattern":"Failed to create account","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/auth.ts","lineNumber":768,"sourceCode":"      const headers = new Headers({\n        'Content-Type': 'application/json',\n      });\n\n      // Forward session cookies from the auth provider\n      if (result.cookies?.length) {\n        for (const cookie of result.cookies) {\n          headers.append('Set-Cookie', cookie);\n        }\n      }\n\n      return new Response(responseBody, { status: 200, headers });\n    } catch (error) {\n      if (error instanceof HTTPException) throw error;\n      const mastra = (ctx as any).mastra;\n      mastra?.getLogger?.()?.error('Sign-up error', {\n        error: error instanceof Error ? { message: error.message, stack: error.stack } : error,\n      });\n      throw new HTTPException(400, { message: 'Failed to create account' });\n    }\n  },\n});\n\n// ============================================================================\n// GET /auth/roles/:roleId/permissions\n// ============================================================================\n\nconst rolePermissionsPathSchema = z.object({ roleId: z.string() });\nconst rolePermissionsResponseSchema = z.object({ roleId: z.string(), permissions: z.array(z.string()) });\n\nexport const GET_ROLE_PERMISSIONS_ROUTE = createRoute({\n  method: 'GET',\n  path: '/auth/roles/:roleId/permissions',\n  requiresAuth: true,\n  responseType: 'json',\n  pathParamSchema: rolePermissionsPathSchema,\n  responseSchema: rolePermissionsResponseSchema,","sourceCodeStart":750,"sourceCodeEnd":786,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/auth.ts#L750-L786","documentation":"Thrown as a 400 by the POST /auth/credentials/sign-up handler when auth.signUp() throws any error that is not already an HTTPException. The original error is logged server-side via the Mastra logger, and the client receives only this generic message, so the real cause (duplicate email, validation failure, storage error) must be read from server logs.","triggerScenarios":"POST /auth/credentials/sign-up where the provider's signUp rejects: email already registered (unique constraint), invalid user data rejected by the provider, or a database/storage failure during user creation.","commonSituations":"Users attempting to register with an email that already has an account; provider backing store down or misconfigured; missing required fields (name) that the provider validates; after provider upgrades that change signUp's expected arguments.","solutions":["Check the server logs for the 'Sign-up error' entry — it contains the underlying error message and stack.","If it's a duplicate account, sign in instead of signing up, or use a password reset for the existing account.","Verify the request body includes valid email, password, and name per the provider's requirements.","Confirm the provider's user store (database) is reachable and migrations have run."],"exampleFix":"// before (client)\nawait auth.signUp({ email, password });\n\n// after (client: check for existing account first / handle 400)\ntry {\n  await auth.signUp({ email, password, name });\n} catch (e) {\n  if (e.status === 400) show('Sign-up failed — the email may already be registered.');\n}","handlingStrategy":"try-catch","validationCode":"const emailOk = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email);\nconst passwordOk = typeof password === 'string' && password.length >= 8;\nconst nameOk = typeof name === 'string' && name.trim().length > 0;\nif (!emailOk || !passwordOk || !nameOk) throw new Error('Invalid sign-up payload');","typeGuard":null,"tryCatchPattern":"try {\n  await signUp(email, password, name);\n} catch (e) {\n  if (e.status === 400) {\n    // Read server logs for the real cause (duplicate email, storage failure)\n    showError('Sign-up failed. If you already have an account, sign in or reset your password.');\n  } else throw e;\n}","preventionTips":["Validate payload shape/requirements client-side before calling sign-up.","Check server logs ('Sign-up error') whenever a 400 occurs — the client message is intentionally generic.","Ensure the provider's user store is reachable and migrated in each environment.","Offer 'sign in instead' UX for likely duplicate-email cases."],"tags":["auth","http-400","sign-up"],"backgroundTag":"account-creation-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}