fix(portal): validate waitlist preferredTime/preferredDate, return 400 on bad input (GRO-2211) #179
Reference in New Issue
Block a user
Delete Branch "fix/gro-2214-portal-waitlist-validation"
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?
What
Defense-in-depth (parent defect GRO-2211): the portal waitlist API must never return a raw 500 for malformed client input.
createWaitlistEntrySchema/updateWaitlistEntrySchemadeclaredpreferredTime/preferredDateas barez.string(), so a malformed value (e.g. a full ISO datetime) was inserted straight into the Postgrestime/datecolumns, throwing aDateTimeParseErrorthat surfaced as an unhandled 500.Changes (
src/routes/portal.ts)preferredTimeconstrained to^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$(HH:MM or HH:MM:SS) on both create and update schemas.preferredDateconstrained to^\d{4}-\d{2}-\d{2}$(YYYY-MM-DD) on both schemas.timecolumn).zValidator, malformed input now returns 400 before touching the DB.Tests (
src/__tests__/waitlist.test.ts)preferredTime(2026-06-09T10:00:00.000Z) → 400 (create + update), no DB write.preferredDate(03/25/2026) → 400.preferredTime(25:99) → 400.HH:MM:SS→ 201;HH:MMnormalized toHH:MM:SSon insert.Verification
npm run typecheck— cleannpm run lint— 0 errors (7 pre-existing warnings)npm test— 630 passed (43 files)Acceptance criteria
preferredTime→ 400 with validation messageHH:MM:SS→ 201 and insertsResolves GRO-2214 (parent GRO-2211).