StackMatch

Supabase "row-level security policy" error in a Lovable or Bolt app? How to fix it (2026)

Prices and facts checked on each tool's official site. Plans change often, so confirm before you pay.

Your AI-built app worked in the preview, then saving a form fails with new row violates row-level security policy for table, or your list suddenly shows no data. Both usually come from the same place: your Supabase database's row level security (RLS) rules. Here's what's going on in plain English, the safe fix, and when it's worth getting help.

Quick answer

RLS is a set of rules inside your database that decide which rows each user can read or change. The error means no rule allows what your app just tried. Don't turn RLS off; that makes your data public. Instead, find which action failed (read, add, change or delete), check that the user is signed in, and ask your builder to add one policy for that action, such as Signed-in users can insert rows where user_id is their own id. If the AI keeps going in circles, or the table holds user data or payments, have a person check it.

Why this happens in Lovable and Bolt apps

Both builders store your data in Postgres with Supabase-style RLS. Lovable sets up policies automatically when it builds features that store user data, and Bolt uses Supabase when you connect it (Pro and Teams plans) for your database and logins. The AI writes the policies as it goes, so a new table, a new form or a change to sign-in can leave one action without a rule. Supabase says that once RLS is on, no data is reachable through the API until you create policies, so a missing policy shows up as an error or as missing data.

The 4 usual causes

  1. No policy for that action. Each action needs its own rule: SELECT (read), INSERT (add), UPDATE (change) and DELETE (remove). An app that can show rows but not save them is often missing its INSERT policy.
  2. The user isn't signed in. Supabase's auth.uid() returns nothing for signed-out visitors, so a rule like auth.uid() = user_id quietly fails for them. If the form is meant for signed-out visitors, it needs a rule for the anon role; if not, the page should require sign-in first.
  3. The row doesn't carry the user's id. An INSERT rule checks the new row. If your code never fills in user_id, or fills in the wrong id, the check fails with the RLS error.
  4. An update has no matching read rule. Supabase notes that an UPDATE needs a SELECT policy too. Without one, the update matches zero rows and nothing changes, with no error at all.

Step 1: find which action failed

Open your browser console (Cmd + Option + J on Mac, Ctrl + Shift + I on Windows), repeat the action, and copy the red error. new row violates row-level security policy means an INSERT or UPDATE. Error code 42501 means permission denied. infinite recursion detected in policy means two tables' rules read each other (see Step 4). Empty results with no error usually mean a SELECT rule is filtering the rows out.

Step 2: read your current policies

  • Lovable: go to More → Database, select Manage, then Policies. Each policy shows its command (SELECT, INSERT, UPDATE or DELETE), who it applies to (authenticated or anon), and its rule. The view is read-only; you change policies by asking Lovable in chat.
  • Bolt with Supabase: open your Supabase project's dashboard and look at the table's policies there, or click the database icon in Bolt to see your connected database.

Look for the table in the error and check whether the failing action has a policy at all.

Step 3: ask for one specific policy, not a rewrite

Paste the exact error and describe the rule in plain words, for example:

Saving a note fails with: new row violates row-level security policy for table "notes". Signed-in users should be able to add notes where user_id is their own id, and read, change and delete only their own notes. Don't disable RLS. Explain the change before making it.

One rule per action keeps things clear; Supabase itself recommends a separate policy for SELECT, INSERT, UPDATE and DELETE rather than one catch-all. In Lovable, the free security scan (it also runs every time you publish) flags tables without RLS and rules that let everyone through, and Try to fix all draws from your 10 free fixes before it uses credits.

Step 4: watch for the risky shortcuts

  • Turning RLS off or adding a rule like using (true) for everyone makes the error vanish by opening the table to anyone. Only do that for data that's meant to be public.
  • Using the secret or service_role key in the browser skips RLS completely. Supabase says never to expose it to users; it belongs only in server code.
  • Infinite recursion (error 42P17) happens with sharing features, where two tables' policies check each other. The fix is a small security definer function, which is easy to get wrong, so it's a good moment to have someone look.
  • Policies that trust user-editable data, such as a role stored in user metadata, can be changed by the user themselves.

When it's time to get help

Plenty of RLS errors are one missing policy you can add in a minute. Get a second pair of eyes when:

  • The AI has rewritten the same policies several times and the error keeps coming back.
  • You see infinite recursion, or data from one user showing up for another.
  • The table holds personal data, orders or Stripe payments, where a wrong rule can leak data or lose sales.
  • You're about to launch and want the whole app checked, not just one table.
OptionPriceWhat you get
App Audit$49 one-timeA plain-English written fix list, including which tables and policies are risky and the order to fix them in, within 3 business days
Payments Live$199 one-timeStripe payments wired into your app and tested with test cards before going live
Launch Pack$499 one-timeAgreed bug fixes, Stripe payments, and your app published on your own domain with HTTPS

We confirm the scope by email before any work starts, and you can ask questions first without paying. Never send anyone your password or your Supabase secret key.

Related guides

Sources

FAQ

What does "new row violates row-level security policy" mean?

Your Supabase table has row level security turned on, and no policy allows that insert for the user making it. Usually there is no INSERT policy at all, the user isn't signed in, or the row's user_id doesn't match the signed-in user.

Should I just turn RLS off to fix the error?

No. Supabase warns that a table in an exposed schema without RLS is readable and writable by anyone with access to it. Turning RLS off makes the error go away by making your data public. Add the missing policy instead.

Why does my Supabase query return an empty list instead of an error?

When a SELECT policy filters a row out, Postgres raises no error; it just returns zero rows. A missing SELECT policy, a signed-out user, or an update with no matching SELECT policy all look like "no data" rather than a failure.

When should I pay someone to fix my Supabase policies?

When the AI keeps rewriting policies without fixing the error, when you see "infinite recursion detected in policy", or before you launch an app that stores other people's data or payments. StackMatch's App Audit is $49 for a written fix list, and fixes plus launch start at $199.

Some links are referral links; we may earn a commission at no extra cost to you. It never changes our recommendations.

Newsletter

Get the monthly "which AI tool" email

One short, beginner-friendly email a month. No spam.

Form not showing? Subscribe here