{
  "id": 20219086,
  "title": "\"infinite recursion detected in policy for relation\" in a Supabase app",
  "url": "https://urgent.news/2026/11/15/infinite-recursion-detected-in-policy-for-relation-in-a-supabase-app",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-15T19:32:37.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/za_s_/infinite-recursion-detected-in-policy-for-relation-in-a-supabase-app-4h2i"
  },
  "original_language": "en",
  "account": "The error \"infinite recursion detected in policy for relation profiles\" resulted from a Supabase app's row level security (RLS) policy. The policy asked the database a question it couldn't answer, causing PostgreSQL to stop the query to prevent an infinite loop. This issue arose due to a subquery referencing the same table (profiles) within the policy.\n\nTo resolve this, administrators were advised to use a security definer function that runs as the role that created it, bypassing RLS. This function checks if the current user is an admin and can then return the appropriate result without triggering the infinite recursion error. By implementing these changes, the policy errors were resolved, and the Supabase app could function correctly.",
  "summary": "You added sharing, or teams, or an admin role. Now a page that worked yesterday loads nothing at all, and the console shows this: infinite recursion detected in policy for relation \"profiles\" with the code 42P17 . Nothing is corrupted and no data is lost, but as Supabase's own documentation puts it, \"the query fails for every role the policies apply to\", so this is not one unlucky user. One of…",
  "key_points": [
    "Infinite recursion error in Supabase app's RLS policy",
    "Subquery referencing 'profiles' table caused issue",
    "Security definer function resolved policy errors"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}