0

Mutations & error codes

Queriesused in ~90% of apps

"The insert succeeded — the row is definitely in the table — but my code got back data: null and I spent an hour assuming the write failed." This is the single most common confusion in Supabase mutation code, and it sits right next to a popular blog claim about RLS silently hiding a successful write that turns out, the moment you actually run it, to be false. Both are fixed by learning to read one thing: the error's code.

Core idea. supabase.from(t).insert(row) — with no .select() chained — writes the row and hands back { data: null, error: null }: success, with nothing to show for it, because RETURNING was never requested. error is a normal return value, checked after every call, never thrown unless you opt into .throwOnError(). And the code on that error tells you which layer failed: a PGRST-prefixed code comes from PostgREST itself (row-count expectations, missing exposure); a bare five-character SQLSTATE like 23505 or 42501 comes from Postgres — a constraint or a privilege, including RLS.
Playground, this isn't a screenshot
Live demointeractive
Real Postgres · in your browseridle
Switch to authenticated as alice. The INSERT policy is wide open (with check (true)) — alice may insert a note owned by anyone, including bob. Run the query above as written (owner = bob's uuid). A popular blog claim says this "succeeds silently, the row just isn't visible to you." Predict the result, then run it — and afterward, switch to service_role and run select * from notes; to check whether the row exists.
Querying as
Cmd/Ctrl + Enter
↑ play a little first, then dig in