#28 most commondatabaseLovableBolt.newCursorWindsurfv0

infinite recursion detected in policy for relation

infinite recursion detected in policy for relation "profiles" (code 42P17)

Got a slightly different error? Paste the exact message and get a fix prompt tailored to it.

Paste your error →

What it means

One of your database security rules checks the same table it's protecting, which asks the rule again, forever. It's usually an 'is this user an admin?' check.

How to fix it: paste this prompt into your AI builder

Fix prompt for Lovable, Bolt, Cursor, v0, Windsurf
Supabase says "infinite recursion detected in policy". Find the policy on that table that queries the same table (or a table whose policy queries back). Replace the lookup with a SECURITY DEFINER SQL function (in a non-exposed schema, with set search_path = '') that returns a boolean like is_admin() or is_member(team_id), and use that function in the policy. Give me the SQL migration. Don't loosen security or touch other tables' policies.

If the AI can't fix it: manual steps

  1. Supabase dashboard, Database, Policies: find the policy causing it.

Where this happens

Seen in these AI app builders and editors:

LovableBolt.newCursorWindsurfv0

Sources

Related database errors

Still stuck? Paste your full error and UnstuckMyVibe will match it and hand you the exact fix prompt.

Fix my error →