<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Masaru Nishino</title>
    <description>The latest articles on DEV Community by Masaru Nishino (@kurosworks).</description>
    <link>https://dev.to/kurosworks</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4271570%2Ff3416f5d-b062-4461-a3d5-8d623019ad80.png</url>
      <title>DEV Community: Masaru Nishino</title>
      <link>https://dev.to/kurosworks</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kurosworks"/>
    <language>en</language>
    <item>
      <title>Why your Supabase query returns nothing, with no error (3 common causes)</title>
      <dc:creator>Masaru Nishino</dc:creator>
      <pubDate>Sun, 29 Nov 2026 23:45:34 +0000</pubDate>
      <link>https://dev.to/kurosworks/why-your-supabase-query-returns-nothing-with-no-error-3-common-causes-5a15</link>
      <guid>https://dev.to/kurosworks/why-your-supabase-query-returns-nothing-with-no-error-3-common-causes-5a15</guid>
      <description>&lt;p&gt;"The data is in the table, but my app shows nothing."&lt;/p&gt;

&lt;p&gt;This is one of the most common Supabase questions, especially in apps built with Lovable, Bolt or Cursor. And it's hard to search for, because there is no error. The query succeeds. It just returns &lt;code&gt;[]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Almost every time, the cause is Row Level Security (RLS).&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the dashboard looks fine
&lt;/h2&gt;

&lt;p&gt;The SQL Editor in the Supabase dashboard runs as a database admin, so it skips RLS. Your app doesn't. It runs as &lt;code&gt;anon&lt;/code&gt; (not signed in) or &lt;code&gt;authenticated&lt;/code&gt; (signed in), and RLS decides which rows that user can see.&lt;/p&gt;

&lt;p&gt;So the same query can return 5 rows in the dashboard and 0 rows in your app. Both are "correct".&lt;/p&gt;

&lt;p&gt;To reproduce this, I wrote a small script against a local Supabase. It creates a &lt;code&gt;notes&lt;/code&gt; table with 5 rows: 3 belong to client A, 2 belong to client B. Then it signs in as client A and runs the query three different ways.&lt;/p&gt;

&lt;p&gt;In all three cases, the app got &lt;strong&gt;0 rows and no error&lt;/strong&gt;, while a direct Postgres count showed &lt;strong&gt;5&lt;/strong&gt;. After each fix, client A saw exactly &lt;strong&gt;their own 3 rows&lt;/strong&gt;, and none of client B's.&lt;/p&gt;

&lt;p&gt;Here are the three causes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cause 1: RLS is on, but there is no policy
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;alter&lt;/span&gt; &lt;span class="k"&gt;table&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;notes&lt;/span&gt; &lt;span class="n"&gt;enable&lt;/span&gt; &lt;span class="k"&gt;row&lt;/span&gt; &lt;span class="n"&gt;level&lt;/span&gt; &lt;span class="n"&gt;security&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;-- ...and no policy was created&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When RLS is enabled and no policy allows &lt;code&gt;select&lt;/code&gt;, Postgres returns nothing. It doesn't raise an error. It just filters out every row.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; add a policy that says who can read which rows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="n"&gt;policy&lt;/span&gt; &lt;span class="s2"&gt;"Users can read their own notes"&lt;/span&gt;
&lt;span class="k"&gt;on&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;notes&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="k"&gt;select&lt;/span&gt;
&lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="n"&gt;authenticated&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;owner_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Cause 2: The policy compares the wrong column
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Looks right, but isn't&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;id&lt;/code&gt; is the note's own ID. &lt;code&gt;auth.uid()&lt;/code&gt; is the signed-in user's ID. They are never equal, so the policy matches no rows.&lt;/p&gt;

&lt;p&gt;This one is common in AI-written policies, because &lt;code&gt;id&lt;/code&gt; and &lt;code&gt;user_id&lt;/code&gt; / &lt;code&gt;owner_id&lt;/code&gt; look similar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; compare the column that stores the owner.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;owner_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Cause 3: The query runs before sign-in
&lt;/h2&gt;

&lt;p&gt;The policy is written for &lt;code&gt;authenticated&lt;/code&gt;, but the query runs before the session is ready. At that moment the request is still &lt;code&gt;anon&lt;/code&gt;, and no policy allows &lt;code&gt;anon&lt;/code&gt; to read. Result: 0 rows.&lt;/p&gt;

&lt;p&gt;This often happens when a page loads data on first render, before sign-in has finished, or when a server component uses a client that doesn't have the user's session.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; make sure the user is signed in before you query.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;supabase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// not signed in yet: redirect, or wait for the session&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;supabase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'notes'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'*'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the server (for example in Next.js), use a client that reads the user's session from cookies, so the request runs as that user.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check your own app in one minute
&lt;/h2&gt;

&lt;p&gt;Run the same query in the SQL Editor. If it returns rows there but not in your app, it's almost certainly RLS.&lt;/p&gt;

&lt;p&gt;To see what a real user sees, you can test as that user inside a transaction:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;begin&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;set&lt;/span&gt; &lt;span class="k"&gt;local&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt; &lt;span class="n"&gt;authenticated&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="nf"&gt;set_config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'request.jwt.claims'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'{"sub":"&amp;lt;user-id&amp;gt;"}'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="cm"&gt;(*) from public.notes;  -- what this user can see

rollback;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;&amp;lt;user-id&amp;gt;&lt;/code&gt; with the user's ID from Authentication &amp;gt; Users. If the count is 0 here, the problem is your policy, not your frontend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two "fixes" to avoid
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Turning RLS off.&lt;/strong&gt; The list will show up, but now anyone with your anon key can read every row.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using the &lt;code&gt;service_role&lt;/code&gt; key in the browser.&lt;/strong&gt; It skips RLS completely. Never ship it to the client.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both make the empty list go away by removing the protection.&lt;/p&gt;

&lt;h2&gt;
  
  
  The script
&lt;/h2&gt;

&lt;p&gt;The local script that reproduces all three causes (and fixes each one) is here. It only runs against &lt;code&gt;localhost&lt;/code&gt;, creates a temporary table, and always drops it at the end:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/kuros-works/client-portal-demo/blob/main/scripts/local-seed/README.md#demo-why-a-supabase-query-returns-nothing-no-error" rel="noopener noreferrer"&gt;https://github.com/kuros-works/client-portal-demo/blob/main/scripts/local-seed/README.md#demo-why-a-supabase-query-returns-nothing-no-error&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;I build Next.js + Supabase client portals in Tokyo. If you'd rather have someone find and fix this in your app, I do it as a small fixed-price service on Upwork: &lt;a href="https://www.upwork.com/services/product/development-it-a-supabase-rls-or-permission-error-fixed-in-your-app-2126481891543141476" rel="noopener noreferrer"&gt;https://www.upwork.com/services/product/development-it-a-supabase-rls-or-permission-error-fixed-in-your-app-2126481891543141476&lt;/a&gt;&lt;/p&gt;

</description>
      <category>supabase</category>
      <category>postgres</category>
      <category>security</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
