← All fixes
Supabase: new row violates row-level security policy for table
#126Error
new row violates row-level security policy for table "todos"
Why it happens, and why this works
Row Level Security is on for the table (as it should be) and no INSERT policy allows this row for this user. Usually there's no insert policy at all, the user isn't signed in (the request runs as anon), or the row's user_id doesn't match auth.uid().
Fix
Add an insert policy that matches how you write rows, e.g. create policy "insert own" on todos for insert to authenticated with check (auth.uid() = user_id); and set user_id to the signed-in user's id (or give the column default auth.uid()). Check the client actually has a session. Don't turn RLS off, and never ship the service_role key to the browser; use it only on the server.
Did it work?
No reports yet0 worked0 didn't
Tried it yourself?
Related fixes
Supabase update/delete returns no error but changes 0 rows (RLS blocks it silently)
#135supabase.from('table').update(...).eq('id', x) returns { error: null } but nothing changes; data is [] / count 0. Same for delete. No 42501 error is raised.
Supabase table readable by anyone with the anon key
#2Data in a Supabase table can be fetched from the browser with only the public anon key, no login.
SyntaxError: await is only valid in async functions and the top level bodies of modules
#28SyntaxError: await is only valid in async functions and the top level bodies of modules
nodeVerifiedNo reports yet