Supabase "Cannot coerce the result to a single JSON object" (PGRST116) in a Lovable or Bolt app: fixes (2026)
Prices and facts checked on each tool's official site. Plans change often, so confirm before you pay.
Your Lovable or Bolt app shows a blank profile page, a 406 error in the browser console, or this message from Supabase: Cannot coerce the result to a single JSON object, with code PGRST116. It means the app asked for exactly one row and Supabase found none, or more than one. Here's how to tell which, and how to fix it.
What the error means
The AI-written code almost always ends a query with .single(). Supabase's docs say .single() returns one object instead of a list, and the query result must be exactly one row, otherwise it returns an error. Supabase's error code list describes PGRST116 (HTTP 406) as more than 1 or no items returned when requesting a singular response. The details part of the error tells you which: for example The result contains 0 rows.
Match the situation to the cause
| What you see | Most likely cause |
|---|---|
| Error for new users only, often on a profile or settings page | Their row (usually in profiles) was never created |
| Works for you, fails for other users or when logged out | Row Level Security hides the row, so 0 rows come back |
| Error right after saving or updating something | The update ran but there's no SELECT policy, so .select().single() sees 0 rows |
| Details mention more than 1 row | Duplicate rows, or the filter isn't specific enough |
| Error on a page that loads by ID from the URL | Wrong or missing ID (for example undefined), or the item was deleted |
1. Missing profile row for new users
Many Lovable and Bolt apps keep extra user info in a profiles table and load it with .eq('id', user.id).single(). If nothing created that row when the user signed up, the first query fails. Supabase's docs recommend a database trigger that inserts a row into public.profiles every time a user signs up, and warn that if the trigger fails it can block sign-ups, so test it. Users who signed up before the trigger existed still need their rows added once.
2. Row Level Security hides the row
With RLS on, the policy's using rule decides which rows a user can see. A row they can't see simply isn't returned, so .single() gets 0 rows. Check the table's SELECT policy matches how the app filters, for example auth.uid() = user_id on a column that actually holds the user's ID. Supabase's docs also say an UPDATE needs a corresponding SELECT policy, so an update(...).select().single() call fails without one even when the update itself is allowed. Our Supabase RLS error guide covers writing the policies.
3. Duplicate rows
If the error says more than one row came back, two rows match the filter, often two profile or settings rows for the same user because the app inserted instead of updating. Delete the extra rows, then add a unique constraint on that column (for example user_id) so it can't happen again, and have the app use upsert when it saves.
4. When "no row" is normal: use .maybeSingle()
Supabase's docs say .maybeSingle() works like .single() but the result must be zero or one row, so a missing row gives data: null instead of an error. Use it where an empty result is expected, like checking if a user already has a subscription, and show a sensible empty state. It still errors on 2 or more rows, so it doesn't hide duplicates.
5. Wrong or missing ID in the query
On detail pages the ID often comes from the URL or from the logged-in user. If the page runs before the user has loaded, the filter can be undefined and match nothing. Make the query wait until the ID exists, and check that the item wasn't deleted.
What to paste into Lovable or Bolt
I get PGRST116 "Cannot coerce the result to a single JSON object" on [page]. Don't change any code yet. First tell me: which query uses .single(), what it filters on, whether the row exists for this user, whether RLS has a SELECT policy that lets this user see it, and whether there could be duplicate rows. Then list the fixes in order. Don't turn off Row Level Security and don't use the service role key in browser code.
When it's time to get help
Often it's a missing profile trigger or one policy. Get a second pair of eyes when:
- You fixed one page and the same error shows up on another.
- The AI keeps switching between .single() and .maybeSingle() without fixing the cause.
- Real users are hitting blank pages.
- You're about to launch and want the whole app checked.
| Option | Price | What you get |
|---|---|---|
| App Audit | $49 one-time | A plain-English written fix list for this error and anything else that breaks, within 3 business days |
| Payments Live | $199 one-time | Stripe payments wired into your app and tested with test cards before going live |
| Launch Pack | $499 one-time | Agreed bug fixes, Stripe payments, and your app published on your own domain with HTTPS |
We confirm the scope by email before any work starts, and you can ask questions first without paying. Never send anyone your password or your Supabase secret key.
Related guides
- Data won't save? See the Supabase RLS error guide and Supabase's Oct 30 grants change.
- Works in preview but not live? See works in preview but broken after publishing.
- Getting "duplicate key value violates unique constraint" when saving? See the Supabase 23505 duplicate key guide.
- Not sure what your error means? Paste it into the free error decoder.
Sources
- Supabase: single() (result must be one row, otherwise an error)
- Supabase: maybeSingle() (zero or one row)
- Supabase: PostgREST error codes (PGRST116, 406)
- PostgREST: singular or plural ("Cannot coerce the result to a single JSON object", "The result contains 0 rows")
- Supabase: Row Level Security (using decides visible rows, UPDATE needs a SELECT policy)
- Supabase: managing user data (profiles trigger on sign-up)
FAQ
What does PGRST116 mean in Supabase?
Your app asked Supabase for exactly one row, usually with .single(), but the query found 0 rows or more than 1. Supabase's API returns error code PGRST116 with HTTP status 406 instead of the data.
Should I just switch .single() to .maybeSingle()?
Only when "no row yet" is a normal case, like a profile that hasn't been created. .maybeSingle() returns null instead of an error for 0 rows, but it still errors when more than 1 row matches, so duplicates need a real fix.
Why does it work for me but not for other users?
Usually Row Level Security. RLS hides rows a user isn't allowed to see, so the query returns 0 rows for them. Check the table's SELECT policy, and remember an update followed by .select() also needs a SELECT policy.
Why does a brand-new user get this error on their profile page?
Their profile row doesn't exist yet. Supabase's docs suggest a database trigger that inserts a row into public.profiles every time a user signs up, so the row is always there before the app looks for it.
Some links are referral links; we may earn a commission at no extra cost to you. It never changes our recommendations.