- Symptom
- AuthApiError: Database error saving new user (500, unexpected_failure)Inviting a user from the dashboard fails with the same messageSignups worked until a trigger on auth.users was added
- 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; $$;- Affected
- Supabase Auth on hosted and self-hosted projects with triggers or constraints on auth.users
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders