The Prompt BakeryTemplates and prompts

Fix · Supabase and databases

"JSON object requested, multiple (or no) rows returned" (PGRST116)

What you may see

  • My query for one record fails with an error
  • The page breaks when the record does not exist yet

Most likely cause

The code asked for exactly one row (single), but the query found none or more than one.

Check first (about two minutes)

  1. Run the same filter in the SQL editor: how many rows come back?
  2. If zero: does the row exist for this user, or does a row-level security rule hide it?

The fix prompt

What you type here never leaves your browser. The search runs on this page, and nothing is sent to a server or to an AI.

Kept only in this browser, on this device. Keys and passwords are removed before anything is saved.

Prompt language

Paste it into Claude, ChatGPT, Gemini or Cursor, then follow what it says.

After you tried it, did it work?

Steps

  1. Find the query and the filter it uses.
  2. If "no row" is a normal case (a new user), use the variant that allows zero rows (maybeSingle) and handle null in the page.
  3. If it returns more than one, find why (a missing unique rule) and add a unique constraint through a migration after checking existing data.
  4. If a security rule hides the row, follow the empty-result entry.

Do not do this

  • Do not hide the error with an empty catch block.
  • Do not delete duplicate rows without showing me which ones.

Related

Try another entry

How can we help?

What do you need?
Your email, so we can reply (optional)Only enter your own email. We reply there.