docs(auth): explain why the signup trigger must schema-qualify names (#53695)

## Problem

The User Management guide shows a trigger that copies new users into
`public.profiles`, but it doesn't say why the function sets `search_path
= ''` and writes `public.profiles` in full. A reader who drops the
schema from a table name breaks every sign-up, and the page doesn't
connect that to the `Database error saving new user` response.

Related to
[FDBKIN-40810](https://linear.app/supabase/issue/FDBKIN-40810/document-best-practices-for-security-definer-triggers-on-authusers)
Closes
[DOCS-1715](https://linear.app/supabase/issue/DOCS-1715/explain-why-the-signup-trigger-must-schema-qualify-tables)

## Solution

A caution admonition right after the trigger example on
`/guides/auth/managing-user-data` tells readers to schema-qualify every
non-built-in name in the function, such as `public.profiles`. It
explains that the function sets `search_path = ''`, so Postgres can't
find an unqualified name, the trigger fails, and every sign-up fails
with `Database error saving new user`. The note leaves out the Auth
role's own search path, because it doesn't apply once the function sets
an empty one. For why the search path stays empty, it links to the
"Security `definer` vs `invoker`" section of the database functions
guide instead of repeating it. The SQL example and the rest of the page
are unchanged.

## How to verify

1. On the preview, open `/docs/guides/auth/managing-user-data`.
2. Right after the `handle_new_user` / `on_auth_user_created` SQL
example, a caution note says to schema-qualify names such as
`public.profiles`, says the function's `search_path = ''` is why an
unqualified name fails, and gives the `Database error saving new user`
error.
3. The note's link opens the "Security `definer` vs `invoker`" section
of `/docs/guides/database/functions`.
4. No other text on the page changed.

## Checks

Ran `pnpm turbo run typecheck --filter='...[origin/master]'`, `pnpm
turbo run lint --filter='[origin/master]'` (0 errors), and Prettier
`--check` on the changed file. The error string was checked against
`supabase/auth` `internal/api/signup.go` (`signupNewUser` returns
`Database error saving new user` when the user insert fails). The docs
tests were skipped because they need Docker. A second reader reviewed
the change against the style guide.

## Checklist

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)

---------

Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>
This commit is contained in:
supabase-vercel-tedd[bot] authored and GitHub committed 2026-11-20 16:36:36 -07:00
1 parent edcfad5bae
commit edece97bdc
1 file changed
+6
@@ -60,6 +60,12 @@ create trigger on_auth_user_created
for each row execute procedure public.handle_new_user();
```
<Admonition type="caution">
Put the schema in front of every table, function, and type in this function that isn't built in, such as `public.profiles`. The function sets `search_path = ''`, so Postgres can't find a name like `profiles` without its schema. The trigger then fails, and every sign-up fails with `Database error saving new user`. To learn why the search path stays empty, see [Security `definer` vs `invoker`](/docs/guides/database/functions#security-definer-vs-invoker).
</Admonition>
## Adding and retrieving user metadata
You can assign metadata to users on sign up: