Supabase · api · fg-0205
Supabase signUp fails with Database error saving new user after adding a profiles trigger
AuthApiError: Database error saving new user (500, unexpected_failure)
Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100
Cause
A trigger on auth.users runs inside the signup transaction, so any error in it (missing column, NOT NULL, wrong search_path, missing grant) rolls back the whole signup. The Auth role does not see unqualified public tables unless the function is security definer with a fixed search_path.
Fix
Declare the function security definer with search_path set to empty, fully qualify every table, make inserted columns nullable or defaulted, and read the real error in the Auth and Postgres logs.
Apply
create or replace function public.handle_new_user() returns trigger language plpgsql security definer set search_path = '' as $$ begin insert into public.profiles (id, full_name) values (new.id, new.raw_user_meta_data ->> 'full_name'); return new; end; $$;
Affects: Supabase Auth on hosted and self-hosted projects with triggers or constraints on auth.users
Sources
- https://supabase.com/docs/guides/troubleshooting/database-error-saving-new-user-RU_EwB
- https://supabase.com/docs/guides/auth/managing-user-data
- https://github.com/supabase/supabase/issues/563
Have your agent know this before it fails
claude mcp add --transport http footgun https://getfootgun.com/api/mcp