SupabaseDatabase

Supabase query returns [] with no error

data: [] (empty array), error: null, but the rows exist in the table

In short: RLS is filtering the rows out silently. A SELECT that no policy allows returns zero rows, not an error.

Why it happens

With Row Level Security enabled, reads only return rows a SELECT policy permits for the current role. If there's no SELECT policy, or the request is running as anon because the user's session didn't attach, you get an empty array. The dashboard Table Editor bypasses RLS, so the data looks fine there.

How to fix it

  1. Check whether a SELECT policy exists for the role making the request (anon or authenticated).
  2. Log await supabase.auth.getUser() right before the query to confirm the user is signed in.
  3. Make sure the policy's condition matches your data (for example user_id actually holds the auth user's id).
  4. For intentionally public data (like a blog), add a SELECT policy for anon scoped to the public rows only.
Don't: Don't 'fix' it by querying with the secret key from the browser.

Copy-paste fix prompt

Paste into Cursor, Claude Code, Codex, Lovable, Bolt, Replit or v0
I'm getting this error in my app:

data: [] (empty array), error: null, but the rows exist in the table

[Paste the full error, stack trace, and the file it points to here]

Likely cause: RLS is filtering the rows out silently. A SELECT that no policy allows returns zero rows, not an error.

Task: Explain why this query can return an empty array under the table's current RLS policies and session state, then propose the smallest SELECT policy change. Don't touch unrelated tables.

Rules:
- First explain the root cause in 2 sentences and list the files you'll change.
- Make the smallest change that fixes it. Don't refactor unrelated code.
- Don't disable security or checks (RLS, auth, signature verification, type checking, CORS allow-all) to make the error disappear.
- Never print or hard-code secret keys.
- Finish by telling me exactly how to verify the fix.

Common with: Lovable, Bolt, Cursor. Last reviewed 2026-11-13.

Related fixes

← All fixes · Still stuck? Use the diagnose-first prompt