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:
co-authored by
Claude Opus 4.8
parent
8ddc8b7b88
commit
2226f8f746
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user