</>RescueMyRepoFree scan

// guide · Supabase · RLS · debugging · Nov 26, 2026

Supabase form says “Saved” but nothing saved? Fix the silent RLS update

Short answer

  • When Row Level Security filters a row out of an UPDATE, Postgres updates zero rows and returns no error.
  • supabase-js .update() returns no rows by default, so if (!error) toast("Saved") lies.
  • The most common cause: the table has an UPDATE policy but no SELECT policy. Supabase requires both.
  • Fix: chain .select("id") and check for an empty result, then add the missing owner-scoped SELECT policy. Never “fix” it by turning RLS off.

Why it fails silently

RLS acts like a hidden WHERE clause. The PostgreSQL CREATE POLICY docs say rows that fail a policy's USING expression “will not be available for modification (in an UPDATE or DELETE). Typically, such rows are silently suppressed; no error is reported.” The Supabase RLS docs put it in a table: a missing grant or a WITH CHECK violation raises 42501, but a USING clause filtering the row out “raises nothing, matches zero rows.”

Then the client hides it. The supabase-js update docs: “By default, updated rows are not returned. To return it, chain the call with .select().” Their own error-handling example only checks error, and that's the pattern Lovable, Bolt, Cursor and Claude usually generate:

// What AI tools usually write
const { error } = await supabase
  .from("profiles")
  .update({ display_name: name })
  .eq("id", user.id);

if (!error) toast("Saved");   // shows "Saved" even when 0 rows changed

Step 1: make the save tell the truth

Ask for the changed rows back and treat “none” as a failure. This doesn't fix the policy, but it stops users from losing work without knowing.

const { data, error } = await supabase
  .from("profiles")
  .update({ display_name: name })
  .eq("id", user.id)
  .select("id");                 // return the rows that actually changed

if (error) return toast.error(error.message);
if (!data || data.length === 0) {
  // RLS filtered the row out, the id was wrong, or the user is signed out
  return toast.error("Not saved. Please sign in again or refresh.");
}
toast("Saved");

Do the same for .delete(), which is filtered the same way. Inserts are different: a blocked INSERT always raises “new row violates row-level security policy”, so you'll already see that one.

Step 2: find which rule is filtering the row

-- Supabase SQL editor: what policies does the table have?
select policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public' and tablename = 'profiles';

-- Is RLS on?
select relname, relrowsecurity from pg_class
where relname = 'profiles';

Compare what you see against the usual causes:

cmd column shows UPDATE but no SELECT (or ALL)   -> add a SELECT policy (most common)
policy compares auth.uid() to the wrong column      -> e.g. id vs user_id on the row
rows have user_id = NULL                             -> rows created by a seed, import or server code
request is signed out (runs as anon)                -> policy is TO authenticated, session expired
filter value is wrong or undefined                  -> .eq("id", undefined) matches nothing
policy is AS RESTRICTIVE with no permissive policy -> restrictive policies never grant access alone

The first line is the one AI tools create most often. Supabase's docs are explicit: “To perform an UPDATE operation, a correspondingSELECT policy is required.” PostgreSQL explains why: an UPDATE that reads columns, which any .eq("id", ...) filter does, also needs the row to pass a SELECT or ALL policy. Also log supabase.auth.getUser() right before the save; an expired session runs as anon.

Step 3: add the policy pair

-- New migration: let owners read AND update their own row
create policy "Users can read own profile"
  on public.profiles for select
  to authenticated
  using ((select auth.uid()) = id);

create policy "Users can update own profile"
  on public.profiles for update
  to authenticated
  using ((select auth.uid()) = id)
  with check ((select auth.uid()) = id);

Use your table's real owner column (user_id, owner_id...). The with check stops a user from moving the row to someone else. If this table also holds role, plan or credits, an owner UPDATE policy lets users edit those too; see Can your users make themselves admin?

Don't do this

alter table ... disable row level security, using (true), or a service_role key in the browser will make the save work, by letting every visitor edit every row. AI tools suggest these when they see “it works if I turn RLS off.” That's the data leak, not the fix.

Step 4: re-test as the user

-- Re-test as a real user, then undo
begin;
set local role authenticated;
set local request.jwt.claim.sub = '<the user''s uuid>';

update public.profiles
set display_name = 'rls test'
where id = '<the user''s uuid>'
returning id;          -- expect 1 row; 0 rows = still blocked

rollback;

This is the pattern Supabase's own RLS tests use (set local role + request.jwt.claim.sub). Supabase's docs warn that a write which matched zero rows still “passes”, so always use returning and check the row count. Also confirm a different user still gets 0 rows.

Upserts behave differently

.upsert() is an INSERT with ON CONFLICT DO UPDATE. Per PostgreSQL, if the existing row fails the UPDATE policy you get an error instead of a silent skip, so it needs INSERT, UPDATE and SELECT policies that all match the owner.

Prompt to paste into Lovable, Cursor or Claude Code

My Supabase app shows "Saved" but the row doesn't change. Debug it without weakening security:
1. Find every client-side .update() / .upsert() / .delete() call. Make each one chain .select('id') and treat an empty result as a failed save with a visible error. Do not show "Saved" unless at least one row came back.
2. For each table those calls touch, list its RLS policies from the migrations (cmd, roles, USING, WITH CHECK). Point out any table that has an UPDATE policy but no SELECT or ALL policy, or whose policy compares auth.uid() to a column the rows don't actually fill in.
3. Write a new migration that adds owner-scoped SELECT policies where missing and a WITH CHECK on UPDATE policies, using the table's real owner column.
Do NOT disable RLS, use using (true), or use the service_role key in the browser. Show me the before/after policies.

Check it automatically

RescueMyRepo's free scan reads your Supabase migrations and flags RLS-enabled tables that have an UPDATE policy but no SELECT or ALL policy, the setup behind most “Saved but nothing saved” bugs. The same scan checks tables without RLS, policies that only check “logged in”, users who can edit their own role, Stripe webhooks, secret keys in the frontend and unauthenticated AI routes.

Scan my repo freePublic GitHub repos · no signup · about a minute

FAQ

Why is there no error when RLS blocks my update?

Because RLS works like an extra WHERE clause. The PostgreSQL docs say rows that fail a policy's USING expression are not available for modification and are typically silently suppressed, with no error reported. Your UPDATE ran fine; it just matched zero rows. Supabase's RLS docs list the same thing: a USING clause filtering the row out raises nothing and matches zero rows.

When does RLS throw an error instead?

Per the Supabase docs, a missing table grant and a WITH CHECK violation both raise error 42501. So does an insert or update with .select() whose new row fails the SELECT policy, and an upsert whose existing row fails the UPDATE policy (PostgreSQL docs). A blocked plain INSERT never fails silently: it raises "new row violates row-level security policy".

Why does my UPDATE need a SELECT policy?

Supabase's docs: "To perform an UPDATE operation, a corresponding SELECT policy is required." PostgreSQL explains why: an UPDATE that reads columns (any .eq('id', ...) filter does) needs SELECT access too, so the row must pass a SELECT or ALL policy as well as the UPDATE policy. With only an UPDATE policy, the filter sees no rows.

Why didn't supabase-js tell me nothing was updated?

The Supabase JavaScript docs say that by default updated rows are not returned; you have to chain .select(). Without it you get data: null and error: null whether one row changed or none did, so if (!error) showSaved() always shows Saved.

Should I just turn off RLS or use the service_role key?

No. Turning off RLS, adding using (true) or calling Supabase with the service_role key from the browser makes the save work by letting every visitor edit every row. Fix the policy so it matches the signed-in owner instead.

Does RescueMyRepo check for this?

Yes, since Nov 26, 2026. The free scan reads your SQL migrations and flags any RLS-enabled table that has an UPDATE policy but no SELECT or ALL policy (dropped policies and service_role-only or restrictive policies don't count). It is a low-severity reliability finding with a fix prompt; if your SELECT policy lives only in the dashboard, add it to a migration so the scan, your teammates and your next environment can see it.

Sources

Behavior per the linked docs, read Nov 26, 2026.