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

  1. The id is not loaded yet. A route param or state variable is still undefined on first render, and the query runs anyway.
  2. The user is not signed in. user.id is undefined, and you filter by user_id.
  3. A numeric id against a uuid column. The table used to have integer ids, or the code assumes it does.
  4. An empty string from a form or select is sent as the value.
  5. A wrong column in the filter. You compare a text column to a uuid, or the other way around.
  6. A template string like eq("id", "${id}") that produces "undefined".

The fix, in order

  1. Log the exact value just before the query. If it is undefined, null or empty, fix the source.
  2. Only run the query when the id exists. In React, use the enabled option of your data hook or an early return.
  3. Check the column type in the Table Editor.
  4. Validate the id on the server before using it.
  5. Show an empty state on a bad id instead of sending it.

Fixes to avoid

  • Do not change the column type to text to stop the error. You lose the guarantees that make joins and policies safe.
  • Do not loosen row-level security or switch to the service_role key because "the query keeps failing". The error is before RLS, so weakening policies will not fix it, and the service_role key 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.