Fixes โบ Database / Supabase RLS
Supabase query returns an empty array (no error)
The error
data: [] โ select works in the SQL editor but returns nothing in the app
Why it happens
Row Level Security is enabled on the table but there is no SELECT policy that matches the current user (or the user isn't signed in). With RLS on and no matching policy, Postgres silently filters every row instead of throwing an error. The SQL editor runs as a superuser, so it bypasses RLS and hides the problem.
How to fix it
- Open Supabase โ Table Editor โ the table โ check 'RLS enabled'.
- Go to Authentication โ Policies and confirm a SELECT policy exists for the right role (authenticated or anon).
- Make sure the client request carries the user's session (supabase.auth.getSession() returns a user).
- Add a policy such as: create policy "read own rows" on public.todos for select to authenticated using (auth.uid() = user_id);
Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)
My Supabase query on the <TABLE> table returns an empty array with no error. RLS is enabled. Do NOT disable RLS. Add a SELECT policy for the authenticated role that allows users to read rows where user_id = auth.uid(), make sure every insert sets user_id to the signed-in user's id, and make sure the query runs only after the auth session has loaded. Show me the SQL migration you used.
FAQ
Should I just turn RLS off?
No. With RLS off, anyone holding your public anon key can read and write the whole table. Add policies instead.
Why does it work in the SQL editor?
The SQL editor runs as the postgres role, which bypasses RLS.
Related fixes
- new row violates row-level security policy for table
- Supabase Edge Function fails with CORS or 'Failed to send a request'
- Supabase Storage upload fails: new row violates row-level security policy (403)
- Postgres error: relation "public.xyz" does not exist
Want the full checklist for this area? Get a Fix Kit ($29)
Featured slot available: reach thousands of vibe coders. Sponsor this week โ
Get one new fix a week
Free newsletter: the newest breakages in Lovable, Bolt, Cursor, Replit and v0 apps, with paste-in fixes.
We only use your email to send the newsletter. Unsubscribe any time. See privacy.