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
- Check whether a SELECT policy exists for the role making the request (
anonorauthenticated). - Log
await supabase.auth.getUser()right before the query to confirm the user is signed in. - Make sure the policy's condition matches your data (for example
user_idactually holds the auth user's id). - For intentionally public data (like a blog), add a SELECT policy for
anonscoped to the public rows only.
Copy-paste fix prompt
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.