From 2226f8f74647a2e97aa5fc082ff4ac8bbd48d292 Mon Sep 17 00:00:00 2001 From: Moheeb Zara Date: Tue, 4 Aug 2026 21:26:55 -0700 Subject: [PATCH] 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) --- lib/actions/area-leads.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/actions/area-leads.ts b/lib/actions/area-leads.ts index fab7267..0aea4d3 100644 --- a/lib/actions/area-leads.ts +++ b/lib/actions/area-leads.ts @@ -121,9 +121,11 @@ export async function updateAreaLead( .eq('id', v.data.id) .eq('space_id', member.space_id) .select() - .single() + .maybeSingle() 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' } await logActivity(supabase, member, 'updated', 'area_lead', v.data.id)