Fix "new row violates row-level security policy" in Supabase
Use this focused Fix Kit to turn the insert error into a safer RLS policy template, a repair prompt, and a two-user isolation test. It does not connect to your Supabase project or scan anything.
{}
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.
Launch Safety Pack
Early-access pack with 15 bundles: AI repair prompts, test scripts, policy templates, MCP guards, and more.
