Menu

Post image 1
Post image 2
Post image 3
Post image 4
Post image 5
Post image 6
Post image 7
Post image 8
Post image 9
Post image 10
1 / 10
0

Two days lost to PGRST116: when Supabase RLS hides a successful write

DEV Community·Vadym Arnaut·19 days ago
#iXe3ctRU
Reading 0:00
15s threshold

TL;DR. Our Supabase upsert wrote the row. The chained .select().single() returned PGRST116. The wrapper read that as a failed write. The frontend retried. The retry was wrong. Two days to find why. We've been running an LMS on Supabase for the past several months — auth, RLS on every table, FastAPI talking to Postgres. The bug below cost us two days last quarter, and the fix changed how we read PGRST116 in our wrapper. The setting We have a quiz_attempts table. Each attempt gets created on quiz start, updated as the student progresses. The update is an upsert because a retry of the same attempt_id should patch the existing row, not insert a duplicate. const { data , error } = await supabase . from ( ' quiz_attempts ' ) . upsert ({ id , student_id , quiz_id , attempt_count }) . select () . single (); Enter fullscreen mode Exit fullscreen mode The .select().single() chain returns the upserted row so we can show the student their new state.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More