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.
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
- A resource ID is required when using memory. Provide…
- Agent " " does not have memory configured
- Agent does not support recover. Only durable agents…
- Agent ID is required
- Agent ID is required
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/0eb4715d5b83c158.
Report an issue: GitHub.
Appendix: 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)