polish(ops): friendly not-found message on cross-space area-lead update

updateAreaLead used .single(), which errors (raw PostgREST message) rather than
returning null when the id isn't in the caller's space. Switch to .maybeSingle()
so the existing 'Area lead not found' guard is reached, matching deleteAreaLead.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
Moheeb Zara
2026-08-04 21:26:55 -07:00
co-authored by Claude Opus 4.8
parent 8ddc8b7b88
commit 2226f8f746
+3 -1
View File
@@ -121,9 +121,11 @@ export async function updateAreaLead(
.eq('id', v.data.id) .eq('id', v.data.id)
.eq('space_id', member.space_id) .eq('space_id', member.space_id)
.select() .select()
.single() .maybeSingle()
if (error) return { error: error.message } if (error) return { error: error.message }
// A cross-space / missing id matches 0 rows; surface the friendly message
// (maybeSingle returns null rather than erroring, unlike single()).
if (!data) return { error: 'Area lead not found' } if (!data) return { error: 'Area lead not found' }
await logActivity(supabase, member, 'updated', 'area_lead', v.data.id) await logActivity(supabase, member, 'updated', 'area_lead', v.data.id)