SupabaseS
Supabase12mo ago
Mio

Sign-Up Error: "Database error saving new user"

Hi everyone,

I’m new to Supabase and currently building a Flutter app with a sign-up feature. I’ve run into an issue and could really use some help.

When I try to sign up a new user, I get this error:

AuthException(message: {"code":"unexpected_failure","message":"Database error saving new user"}, statusCode: 500, errorCode: null)


Here’s the part of my code where the sign-up happens:

final supabase = Supabase.instance.client;

Future<void> _signUp() async {
if (!_formKey.currentState!.validate()) return;

setState(() {
_isLoading = true;
_errorMessage = null;
});

try {
final email = _emailController.text.trim();
final password = _passwordController.text.trim();

final authResponse = await supabase.auth.signUp(
email: email,
password: password,
);

if (authResponse.user != null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Welcome ${authResponse.user!.email!}')),
);
Navigator.of(context).pushReplacementNamed('/choice');
} else if (authResponse.error != null) {
setState(() {
_errorMessage = authResponse.error.message;
});
}
} catch (e) {
setState(() {
_errorMessage = 'An error occurred: $e';
});
print('Error during sign-up: $e');
} finally {
setState(() {
_isLoading = false;
});
}
}

I’ve been stuck on this and can’t figure out what’s causing the "unexpected_failure" error 🥲. Has anyone else experienced this or know how to fix it? Any tips or advice would be really appreciated!

Thanks in advance!
Was this page helpful?