mastra-ai/mastra · error · HTTPException
Failed to create account
Error message
Failed to create account
What it means
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.
Source
Thrown at packages/server/src/server/handlers/auth.ts:768
const headers = new Headers({
'Content-Type': 'application/json',
});
// Forward session cookies from the auth provider
if (result.cookies?.length) {
for (const cookie of result.cookies) {
headers.append('Set-Cookie', cookie);
}
}
return new Response(responseBody, { status: 200, headers });
} catch (error) {
if (error instanceof HTTPException) throw error;
const mastra = (ctx as any).mastra;
mastra?.getLogger?.()?.error('Sign-up error', {
error: error instanceof Error ? { message: error.message, stack: error.stack } : error,
});
throw new HTTPException(400, { message: 'Failed to create account' });
}
},
});
// ============================================================================
// GET /auth/roles/:roleId/permissions
// ============================================================================
const rolePermissionsPathSchema = z.object({ roleId: z.string() });
const rolePermissionsResponseSchema = z.object({ roleId: z.string(), permissions: z.array(z.string()) });
export const GET_ROLE_PERMISSIONS_ROUTE = createRoute({
method: 'GET',
path: '/auth/roles/:roleId/permissions',
requiresAuth: true,
responseType: 'json',
pathParamSchema: rolePermissionsPathSchema,
responseSchema: rolePermissionsResponseSchema,View on GitHub (pinned to 75dd419e61)
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.
Example fix
// before (client)
await auth.signUp({ email, password });
// after (client: check for existing account first / handle 400)
try {
await auth.signUp({ email, password, name });
} catch (e) {
if (e.status === 400) show('Sign-up failed — the email may already be registered.');
} Defensive patterns
Strategy: try-catch
Validate before calling
const emailOk = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
const passwordOk = typeof password === 'string' && password.length >= 8;
const nameOk = typeof name === 'string' && name.trim().length > 0;
if (!emailOk || !passwordOk || !nameOk) throw new Error('Invalid sign-up payload'); Try / catch
try {
await signUp(email, password, name);
} catch (e) {
if (e.status === 400) {
// Read server logs for the real cause (duplicate email, storage failure)
showError('Sign-up failed. If you already have an account, sign in or reset your password.');
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- State token has expired
- Clerk JWKS URI, secret key and publishable key are required,
- Cookie password must be at least 32 characters for SSO. Set
- Redirect URI is required for SSO login
- Token exchange failed: ${error}
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/0eb4715d5b83c158.
Report an issue: GitHub.