fix(GRO-2235): return 409 on duplicate portal waitlist submit #189
Reference in New Issue
Block a user
Delete Branch "flea/gro-2235-waitlist-duplicate-409"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
GRO-2235 — Portal Book New: duplicate waitlist submit returns 500 instead of 409
Source: triage of GRO-2233.
Problem
POST /api/portal/waitlistinserted the entry without catching the partialunique-index violation
idx_waitlist_active_unique(client_id, pet_id, service_id, preferred_date, preferred_time) WHERE status='active'.An exact duplicate active booking threw an unhandled SQLSTATE
23505, whichsurfaced as a generic
500.Fix
Wrap the insert in a try/catch in the handler. On
23505return409 Conflictwith{"error":"You already have a booking for this pet at that date and time."}.Any other error is re-thrown and still surfaces as
500. The first insert isunchanged and still returns
201.Acceptance criteria
409with friendly JSON message (not500)23505) specifically; unrelated errors still500201Tests
New
src/__tests__/portalWaitlistDuplicate.test.ts:20123505) →409friendly message23502) →500npx tsc --noEmitclean; portal + waitlist suites pass (83/83).cc @cpfarhood