← All errors · SupabaseSupabase database & RLS errors

Supabase UPDATE succeeds with 0 rows and no error (RLS)

What you see

A supabase.from(...).update(...) call comes back as a success: there is no error, but the row did not change. If you did not chain .select(), updated rows are not returned, so a 0-row update looks the same as a successful one. If you chain .select() or use RETURNING in SQL, nothing is returned and there is still no error. There is no error text to quote. This page was prompted by a community report of the same silent-success pattern; every behavior claim below is from Supabase's and Postgres's own docs.

What it means

Postgres does not treat an UPDATE that matches zero rows as an error. Row Level Security uses that same rule. A policy's USING expression decides which existing rows are visible for an update. Rows that fail USING are not available to modify, and Postgres typically suppresses them with no error. Supabase's RLS guide lists three ways a write is denied: a missing grant raises 42501, a WITH CHECK violation raises 42501, and a USING clause that filters the row out raises nothing and matches zero rows. On top of that, the supabase-js update() method does not return updated rows unless you chain .select() after your filters, so code that only checks error will treat a blocked update as success. A missing or incomplete policy is a common cause, but a filter that matches no rows looks the same.

Likely causes

How to fix it

  1. Make the 0-row case visible before you change policies. The JavaScript update() docs say updated rows are not returned by default; chain .select() after your filters and check whether any rows came back:

    const { data, error } = await supabase
      .from('profiles')
      .update({ avatar_url: 'updated.png' })
      .eq('user_id', user.id)
      .select()
    
    if (error) throw error
    if (!data?.length) {
      // No error, but the update matched 0 rows:
      // RLS hid the row, or the filter matched nothing.
    }
  2. Add or fix the UPDATE policy. It needs a USING clause that decides which existing rows can be updated. Add a WITH CHECK clause for what the resulting row is allowed to look like, which stops a user from reassigning user_id to someone else. If you omit WITH CHECK, USING is used for both checks:

    create policy "Users can update their own profile."
    on profiles for update
    to authenticated
    using ( (select auth.uid()) = user_id )       -- checks the existing row
    with check ( (select auth.uid()) = user_id ); -- checks the resulting row
  3. Add a matching SELECT policy for the same role. Supabase's RLS guide cautions that an UPDATE needs a corresponding SELECT policy, and will not work as expected without one:

    create policy "Users can view their own profile."
    on profiles for select
    to authenticated
    using ( (select auth.uid()) = user_id );
  4. Test with two different users, as Supabase's policy tests do: the owner should get the updated row back, and another signed-in user should update no rows. In SQL, add RETURNING and assert the returned value. A USING denial raises nothing and matches zero rows, so an empty RETURNING result is the signal, not an error. Then read the target row as the owner to prove it is intact. Never treat "the statement did not throw" as proof that the write happened.

    -- As the owner: the update must return the new value
    set local role authenticated;
    set local request.jwt.claim.sub = '11111111-1111-1111-1111-111111111111';
    update profiles set avatar_url = 'updated.png'
      where user_id = '11111111-1111-1111-1111-111111111111'
      returning avatar_url;
    
    -- As another signed-in user: this should return no rows, and raise no error
    set local request.jwt.claim.sub = '22222222-2222-2222-2222-222222222222';
    update profiles set avatar_url = 'stolen.png'
      returning avatar_url;
  5. If you do get an error, you are on a different path. A missing table grant and a WITH CHECK violation both raise 42501. Those are covered on the permission-denied and "new row violates row-level security policy" pages, not this one.

Still stuck after trying this? Get it fixed for $49, or you don't pay.

Prevent this next time

FAQ

What does "Supabase UPDATE succeeds with 0 rows and no error (RLS)" mean?

Postgres does not treat an UPDATE that matches zero rows as an error. Row Level Security uses that same rule. A policy's USING expression decides which existing rows are visible for an update. Rows that fail USING are not available to modify, and Postgres typically suppresses them with no error. Supabase's RLS guide lists three ways a write is denied: a missing grant raises 42501, a WITH CHECK violation raises 42501, and a USING clause that filters the row out raises nothing and matches zero rows. On top of that, the supabase-js update() method does not return updated rows unless you chain .select() after your filters, so code that only checks error will treat a blocked update as success. A missing or incomplete policy is a common cause, but a filter that matches no rows looks the same.

What usually causes it?

An UPDATE policy USING clause filters the row out for the current user, so the statement matches zero rows and raises nothing. The table has an UPDATE policy but no corresponding SELECT policy. Supabase's RLS guide says an UPDATE needs a SELECT policy, and without one the update will not work as expected. The client is signed in as a different user than the row's owner, or has no session, so the USING expression is false. The .eq() (or other) filter matches no rows. Postgres also treats that as success with a count of 0. The code only checks error and does not chain .select() or RETURNING, so a 0-row update is indistinguishable from a 1-row update.

How do I fix it?

1. Make the 0-row case visible before you change policies. The JavaScript update() docs say updated rows are not returned by default; chain .select() after your filters and check whether any rows came back: 2. Add or fix the UPDATE policy. It needs a USING clause that decides which existing rows can be updated. Add a WITH CHECK clause for what the resulting row is allowed to look like, which stops a user from reassigning user_id to someone else. If you omit WITH CHECK, USING is used for both checks: 3. Add a matching SELECT policy for the same role. Supabase's RLS guide cautions that an UPDATE needs a corresponding SELECT policy, and will not work as expected without one: 4. Test with two different users, as Supabase's policy tests do: the owner should get the updated row back, and another signed-in user should update no rows. In SQL, add RETURNING and assert the returned value. A USING denial raises nothing and matches zero rows, so an empty RETURNING result is the signal, not an error. Then read the target row as the owner to prove it is intact. Never treat "the statement did not throw" as proof that the write happened. 5. If you do get an error, you are on a different path. A missing table grant and a WITH CHECK violation both raise 42501. Those are covered on the permission-denied and "new row violates row-level security policy" pages, not this one.

Last checked against official docs on . Sources: Supabase docs: Row Level Security, Supabase docs: JavaScript update(), Supabase docs: JavaScript select() modifier, PostgreSQL docs: CREATE POLICY, PostgreSQL docs: UPDATE.

Related errors

More Supabase errors and fixes →

Tools that help

  • Railway: Deploy backends and databases; new users get $20 credit.

Some links on this page are affiliate links: if you sign up or buy through them, FixStack may earn a commission at no extra cost to you. Learn more.

Get new fixes weekly

No spam. Unsubscribe anytime. Privacy