Your Supabase query fails with:
{"code":"22P02","message":"invalid input syntax for type uuid: \"undefined\""} The value in the message is often the string undefined, null, an empty string, or a number. It tends to appear on a detail page, a dashboard filter or right after login. It looks like a database problem. It is almost always a bug in what your app sent.
What it means
The column is of type uuid, and the value sent in the query is not a valid UUID such as 3f2b8c1e-9a4d-4c7e-b1a2-5d6e7f8a9b0c. Postgres refuses to cast it and returns 22P02 before it even looks at your rows or policies.
The 6 usual causes
- The id is not loaded yet. A route param or state variable is still
undefinedon first render, and the query runs anyway. - The user is not signed in.
user.idisundefined, and you filter byuser_id. - A numeric id against a uuid column. The table used to have integer ids, or the code assumes it does.
- An empty string from a form or select is sent as the value.
- A wrong column in the filter. You compare a text column to a uuid, or the other way around.
- A template string like
eq("id", "${id}")that produces"undefined".
The fix, in order
- Log the exact value just before the query. If it is
undefined,nullor empty, fix the source. - Only run the query when the id exists. In React, use the
enabledoption of your data hook or an early return. - Check the column type in the Table Editor.
- Validate the id on the server before using it.
- Show an empty state on a bad id instead of sending it.
Fixes to avoid
- Do not change the column type to
textto stop the error. You lose the guarantees that make joins and policies safe. - Do not loosen row-level security or switch to the
service_rolekey because "the query keeps failing". The error is before RLS, so weakening policies will not fix it, and theservice_rolekey skips RLS entirely and must stay off the client. - Do not trust an id from the URL as proof that someone may see that row. The policy must check
auth.uid().
A policy that fits
create policy "own rows" on public.projects for select to authenticated using (user_id = auth.uid()); Check what your site exposes
After fixing the bug, test from the outside: with only the public anon key and no login, you should get no rows. The free read-only check at https://proofforge.live looks at a deployed site for open Supabase data, leaked keys and exposed files, and lists what it could not test. For user-to-user access, use the free two-account test: https://proofforge.live/two-account-test
Paid one-time fix reports are $9, $29 and $79, and the free scan does not require them.

