LeakPatrol › Guides

Supabase select returns an empty array, but the data is there

By LeakPatrol · Updated 20 November 2026

You can see the rows in the Supabase Table Editor, but supabase.from('table').select() in your app returns [] with no error. Or .single() fails with PGRST116: JSON object requested, multiple (or no) rows returned. In almost every case this is Row Level Security doing its job: RLS doesn't raise an error on reads, it silently filters out every row you aren't allowed to see. The Table Editor uses an admin role, so it sees everything. Here are the causes, most common first.

1. RLS is on, but there's no SELECT policy

With RLS enabled and no policy for select, every read returns zero rows. Apps built with Lovable, Bolt or Cursor often get an INSERT policy (so saving works) but no SELECT policy. Check what exists:

select policyname, cmd, roles, qual
from pg_policies
where tablename = 'your_table';

If there's no row with cmd = SELECT or ALL, add one. For data each user owns:

create policy "Users read their own rows"
on public.your_table for select
to authenticated
using ((select auth.uid()) = user_id);

2. The request runs as anon, not as the signed-in user

A policy to authenticated or using (auth.uid() = user_id) returns nothing when the query is sent before the session has loaded, from a Supabase client created on the server without the user's token, or after the session expired. Log (await supabase.auth.getSession()).data.session right before the query. If it's null, wait for the session (or use onAuthStateChange) before querying.

3. The rows don't match the policy

The policy compares user_id, but the rows were inserted with user_id empty, or with a different id (a profile id instead of the auth user id). Check:

select id, user_id from public.your_table limit 20;

If user_id is null, set a default so new rows get it automatically: alter table public.your_table alter column user_id set default auth.uid();, then fix the old rows.

4. A joined table has no SELECT policy

With select('*, profiles(*)'), the embedded table is filtered by its own policies. The main rows come back, but the joined part is null or empty, and with an inner join (profiles!inner(*)) the main rows disappear too. Add a SELECT policy on the joined table.

5. You're looking at a different project

It happens more than you'd think: the app's VITE_SUPABASE_URL points at a dev or old project while you look at the data in another. Compare the project ref in the URL with the dashboard.

Test the policy as a real user

In the SQL editor, run the query as a specific user, inside a transaction so nothing sticks:

begin;
set local role authenticated;
set local request.jwt.claims = '{"sub":"USER-UUID-HERE","role":"authenticated"}';
select * from public.your_table;
rollback;

If this returns the rows, the policy is right and the problem is in the app (cause 2 or 5). If it returns nothing, fix the policy or the data (causes 1, 3, 4).

Empty array vs 42501

If you get an error instead, permission denied for table (code 42501), it's a different problem: the role has no grant on the table at all, which is the default for new tables since Supabase's 30 October 2026 change. See the 42501 fix.

What not to do

A prompt to paste into Lovable, Bolt or Cursor

My Supabase query on the "your_table" table returns an empty array,
but the rows exist. Fix it safely:
1. List the RLS policies on this table and any table it joins.
2. Add a SELECT policy so signed-in users can read only their own
   rows (auth.uid() = user_id). Keep RLS enabled.
3. Make sure the query only runs after the auth session has loaded.
4. Make sure inserts set user_id (default auth.uid()).
Do not disable RLS, do not use "using (true)" for user data, and do
not use the service_role key in the frontend.

Need policies written for you? Our free RLS policy generator builds them from your table name and owner column. And once it works, LeakPatrol's free scan checks your live app for leaked keys and other common mistakes in about a minute.

Check your app in a minute

Free, read-only, no sign-up. Every problem comes with a plain-English fix and a prompt for your AI tool.

Get the 10-point checklist

Every check we run on AI-built apps, with how to do each one yourself. Straight to your inbox.

Questions

Why does Supabase return an empty array with no error?

Row Level Security filters rows silently on reads. If no policy allows the current user to see a row, it is left out of the result instead of raising an error. The Table Editor uses an admin role, so it still shows every row.

Why does .single() fail with PGRST116?

PGRST116 means the query returned zero (or more than one) rows when exactly one was expected. With RLS this usually means no policy lets the current user read that row, or the user is not signed in yet.

Should I disable RLS to fix an empty result?

No. Disabling RLS makes the table readable by anyone with your public anon key. Add a SELECT policy that matches your data instead, for example auth.uid() = user_id.

How do I test a Supabase RLS policy as a user?

In the SQL editor, inside begin and rollback, run set local role authenticated and set local request.jwt.claims with the user id as sub, then run your select. You see exactly what that user would see.

More guides