Supabase Row Level Security and Storage guides
Row Level Security decides what every Supabase API request can read and write, including Storage files and Realtime events. These guides cover the errors it produces and how to fix policies without opening your data to everyone.
- Supabase “new row violates row-level security policy” – causes and fixWhy Supabase returns 'new row violates row-level security policy' (42501) on insert, upsert or storage upload, and the exact policy that fixes each case.
- Supabase “must be owner of table objects” – what it means and what to run insteadWhy 'must be owner of table objects' appears when you enable RLS or add policies on Supabase storage.objects, and the SQL statements that work instead.
- Supabase “permission denied for table” – a missing GRANT, not a missing policyWhy Supabase returns 'permission denied for table' (42501) for anon or signed-in users, the GRANT that fixes it, and why new tables need explicit grants.
- Supabase “infinite recursion detected in policy for relation” – cause and fixWhy 'infinite recursion detected in policy for relation' happens when an RLS policy queries its own table, and the security definer function that fixes it.
- Supabase auth.uid() returns null – where it works, where it can't, and how to test policiesWhy auth.uid() is null in the Supabase SQL Editor, migrations, cron jobs and server code, how to test RLS as a real user, and how to pass the user's JWT.
- Supabase “duplicate key value violates unique constraint” on upsert – the five causesWhy Supabase upsert and insert fail with 'duplicate key value violates unique constraint' (23505, 409): onConflict, missing unique index, out-of-sync sequences.
- Supabase Realtime subscribed but no postgres_changes events – the checklistYour Supabase Realtime channel says SUBSCRIBED but no INSERT, UPDATE or DELETE events arrive. Check the publication, RLS, grants, filters and replica identity.
- Supabase PGRST116 “Cannot coerce the result to a single JSON object” – .single() explainedWhy supabase-js .single() fails with PGRST116 'Cannot coerce the result to a single JSON object' (406), when to use maybeSingle(), and how RLS hides rows.
- Supabase Storage “Object not found” (404) – when the file is really thereWhy Supabase Storage returns 'Object not found' (404) from createSignedUrl or download when the file exists: wrong path, missing SELECT policy, anon client.
- Slow Supabase queries with RLS – (select auth.uid()), indexes and the other fixesFix the Supabase 'Auth RLS Initialization Plan' warning and slow RLS queries: (select auth.uid()), indexes on policy columns, roles and fewer policies.