David Ewins
Error library

Supabase .single() fails with PGRST116 for a row you know exists

SupabaseConfirmed fix

supabase-js 2.89

Error
{"code": "PGRST116", "details": "The result contains 0 rows", "message": "JSON object requested, multiple (or no) rows returned"}

Cause

Row Level Security only had a read policy for the row's owner. A second role that also needed the row got zero rows back, which .single() reports as PGRST116, not a permission error.

Fix

Either add an RLS policy for that role, or read the data through a backend endpoint that checks the relationship and uses the service role. Use .maybeSingle() if zero rows is a legitimate result.

More Supabase errors

Search all errors