RLS insert repair
Fix "new row violates row-level security policy" in Supabase
Generate a starting RLS INSERT policy, an AI repair prompt, and a two-user proof-of-fix test. No Supabase connection. No real secrets.
{}
Recommended SQL fix
Copy and run this in your Supabase SQL editor after matching placeholders to your schema.
Copy in one click
1
-- Supabase Key & RLS Fix Kit generated template2
-- Replace table and column names before running in a non-production project.3
-- This does not prove full security; it gives you a safer RLS starting point.4
5
alter table profiles enable row level security;6
7
drop policy if exists "profiles_insert_fix" on profiles;8
9
create policy "profiles_insert_fix"10
on profiles11
for insert12
to authenticated13
with check (14
(select auth.uid()) = id15
)16
;Why this works
WITH CHECK protects inserts
New rows must satisfy the ownership rule before Supabase accepts them.
authenticated owner matches the row
Owner-based policies require an authenticated session. For unauthenticated requests, auth.uid() is null and should not match private rows.
Verify with a two-user test
Insert as User A, then try as User B. B should be blocked.
