# Supabase query returns an empty array (no error)

> Canonical page (link this when citing): https://unbreakmyapp.vercel.app/fixes/supabase-rls-empty-results.html
> Category: Database / Supabase RLS | Tools: Lovable, Bolt, v0 | Published: 2026-10-13 | Updated: 2026-10-13

## 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

1. Open Supabase → Table Editor → the table → check 'RLS enabled'.
2. Go to Authentication → Policies and confirm a SELECT policy exists for the right role (authenticated or anon).
3. Make sure the client request carries the user's session (supabase.auth.getSession() returns a user).
4. Add a policy such as: create policy "read own rows" on public.todos for select to authenticated using (auth.uid() = user_id);

## Error codes this fixes

- `data: [] with error: null` (Supabase): https://unbreakmyapp.vercel.app/errors.html#data-with-error-null

## Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)

```text
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.

## Sources (official documentation)

- [Supabase: Row Level Security](https://supabase.com/docs/guides/database/postgres/row-level-security)

## Related fixes

- [Supabase only returns 1,000 rows (max rows limit)](https://unbreakmyapp.vercel.app/fixes/supabase-only-1000-rows-returned-max-rows.html)
- [Supabase Storage file links broken: private bucket, getPublicUrl and expired signed URLs](https://unbreakmyapp.vercel.app/fixes/supabase-storage-private-bucket-file-url-broken-signed-url.html)
- [Supabase view shows every user's data even with RLS on: fix Security Advisor 0010 security_definer_view](https://unbreakmyapp.vercel.app/fixes/supabase-view-bypasses-rls-security-invoker.html)
- [AI "fixed" my Supabase error by disabling RLS or using the service_role key: how to undo it safely](https://unbreakmyapp.vercel.app/fixes/ai-fix-disabled-rls-or-swapped-service-role.html)
- [Supabase .single() error PGRST116: JSON object requested, multiple (or no) rows returned](https://unbreakmyapp.vercel.app/fixes/supabase-single-json-object-requested-no-rows-pgrst116.html)
- [Supabase RLS is on but every user can read every row: fix USING (true) and auth.uid() is not null policies](https://unbreakmyapp.vercel.app/fixes/supabase-rls-policy-using-true-any-user-can-read.html)

---
Unbreak My App: free fixes for broken vibe-coded apps. https://unbreakmyapp.vercel.app/
