Supabase database
Supabase returns an empty array with no error. Why, and what’s the safe fix?
Your rows exist, but row level security (RLS) is on and no policy lets this user read them, so Supabase returns [] instead of an error. Either the table has no select policy, or the request carries no signed-in user, so a policy written for signed-in users never matches.
TL;DR
- Supabase’s own troubleshooting page gives the same two causes: RLS on with no policy, or a user who doesn’t meet the policy.
- In our lab a signed-in owner got
[]with HTTP 200, and an insert failed with 42501 “new row violates row-level security policy”. - The two quick fixes AI builders suggest, turning RLS off or adding
using (true), each let a logged-out visitor read every row. - The fix: a select policy that matches the owner, plus a check that the request really carries the user’s token.
Why Postgres returns [] instead of an error
RLS works like a hidden where clause on every query. When no policy lets the current user see a row, Postgres doesn’t raise an error. It filters the row out. If it filters out every row, the API answers with an empty list and HTTP 200. That is by design: an error would tell a stranger the rows exist.
Supabase’s troubleshooting page (updated 4 Nov 2026) lists the causes: RLS is enabled and there is no policy, or the user doesn’t meet the policy. A filter that matches nothing gives the same result, so rule that out first.
Writes behave differently. An insert that no policy allows fails loudly. That is often how people notice: reads are empty and inserts fail.
What we saw in the lab
We built a notes table with two users’ rows, turned RLS on and wrote no policy. Then we called it through real PostgREST, the server behind Supabase’s Data API.
alice GET /notes: [] [HTTP 200]
alice POST /notes: {"code":"42501","message":"new row violates row-level security policy for table \"notes\""} [HTTP 403]
rows really in the table (SQL editor / postgres): 2The SQL editor shows both rows because it runs as postgres, which skips RLS. That is why a query can “work in Supabase” and fail in the app. More on that in why auth.uid() is null.
Is a user signed in when the query runs?
The second cause is a request with no user. If the app queries before sign-in finishes, or a server route builds its client without the user’s session, the request runs as anon. A policy written to authenticated never matches, so the result is empty. Supabase’s troubleshooting page suggests this test function. Add it in the SQL editor, call it from the same place in your code as the failing query, then drop it.
create function test_authorization_header() returns json
language sql as $$ select auth.jwt(); $$;
-- In the app: const { data } = await supabase.rpc('test_authorization_header')
-- When you're done:
drop function test_authorization_header;as the app with only the anon key: {"exp": 1796489573, "role": "anon"}
as signed-in alice: {"exp": 1796489573, "sub": "11111111-…", "role": "authenticated"}If it says anon where you expected a user, fix the session, not the policy.
The two quick fixes, tested
Ask an AI builder to “make the data show up” and you will often get one of these. We applied each to a fresh copy and called the API with only the public key, as a logged-out visitor.
alter table public.notes disable row level security;create policy "Enable read access for all users" on public.notes
for select using (true);anon GET /notes: [{"body":"alice: dentist 3pm"}, {"body":"bob: call the bank"}] [HTTP 200]Both make the screen work. Both hand every user’s notes to anyone with your public key, which ships in your site’s JavaScript. Fix A also lets a visitor write and delete rows if the table has the usual grants.
The fix: a policy that matches the owner
alter table public.notes enable row level security;
create policy "read own notes" on public.notes
for select to authenticated
using ((select auth.uid()) = user_id);
create policy "add own notes" on public.notes
for insert to authenticated
with check ((select auth.uid()) = user_id);If the table was created after 30 October 2026, it may also need a grant, or you will see error 42501 “permission denied” instead of an empty list. See “permission denied” on a new table.
How to check it worked
alice GET: [{"body":"alice: dentist 3pm"}] [HTTP 200]
bob GET: [{"body":"bob: call the bank"}] [HTTP 200]
anon GET (no session: looks the same as 'no rows'): [] [HTTP 200]
alice POST: [{"id":4,"user_id":"11111111-…","body":"new"}] [HTTP 201]Do the same with two real accounts in your app: each should see only its own rows, and a signed-out browser should see none. The two-account test walks through it. To find every table with RLS on and no policy, run the query in RLS on every table.
Ask your AI builder to fix it
Built with Lovable, Bolt, Replit or Cursor? Paste this into the chat. It asks for one fix and to see the change before it is applied.
My Supabase query on the notes table returns an empty array with no error. Row level security is on. Do not disable RLS and do not add a policy with using (true). First check whether the request carries a signed-in user (auth.uid() is not null at the time of the query). Then add a select policy for the authenticated role that matches the row owner: using ((select auth.uid()) = user_id), and an insert policy with the same with check. Write it as a new migration. Show me the exact SQL before you apply it, and don't change anything else.Questions people ask
Why does my Supabase query work in the SQL editor but return [] in the app?
The SQL editor runs as the postgres role, which skips row level security, so it sees every row. The app runs as anon or authenticated, so your policies apply. If no policy matches that user, the app gets an empty array.
Why don't I get an error when RLS blocks a select?
Postgres treats RLS as a filter, not a permission check, for reads. Rows the user may not see are left out, so the API returns an empty list with HTTP 200. Inserts and updates that break a policy do return an error.
Is it safe to turn off RLS to fix an empty result?
No. In our lab, turning RLS off let a logged-out visitor read every row with only the public key. Add a policy that matches the owner instead.
Why does .single() give an error instead of an empty array?
.single() expects exactly one row. When RLS filters the row out, there are zero rows, so the client reports an error instead of returning an empty list. The cause is the same: no policy lets this user read the row.
Sources and lab
- Supabase: Why is my select returning an empty data array and I have data in the table? (updated 4 Nov 2026, read 5 Dec 2026): the two causes and the test function.
- Supabase: Row Level Security, read 5 Dec 2026.
- Supabase: Postgres roles: dashboard queries run as postgres.
- Lab: Postgres 17.11 and 18.6 with PostgREST 12.2.12 and a Supabase role shim, real HTTP requests as a logged-out visitor and two signed-in users, 5 Dec 2026. Synthetic data only. Same results on both versions.
Related findings
The checks behind this guide, each with example code, a self-check and the fix.
RLS enabled but no policies (owner locked out)
PL-005Always-true policy
PL-008Row level security not enabled
Free check
Check your migrations for this, free.
Paste a public GitHub repo. The free RLS check reads its supabase/migrations and flags tables with RLS off or no policies, always-true policies, update policies with no WITH CHECK, SECURITY DEFINER functions anyone can call or with no fixed search_path, views that skip RLS and public buckets. It never connects to your database.
Written by Manraj Singh Dhillon. Last checked 5 Dec 2026. Code samples are synthetic and run against your own project; nothing here names a real app. Spotted a mistake? Tell us.