GRO-2172: add missing extended pet fields to create/update schemas #199
Reference in New Issue
Block a user
Delete Branch "fix/gro-2172-pet-extended-fields"
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-2172 — add missing extended pet fields to create/update schemas
Adds 4 extended pet profile fields to
createPetSchema(and via.partial()toupdatePetSchema) insrc/routes/pets.ts. These columns exist (migrations 0034/0036) and are populated by seed data, but were missing from the Zod schemas, soPOST/PATCH /api/petssilently dropped them. GRO-1472 was the original UAT regression.temperamentScorez.number().int().min(1).max(5)integertemperamentFlagsz.array(z.string().max(100)).max(20)jsonb / string[]medicalAlertsz.array(z.object({type,description,severity})).max(50)jsonb / MedicalAlert[]preferredCutsz.array(z.string().max(200)).max(20)jsonb / string[]Handler
POST /andPATCH /:idnow destructuremedicalAlertsand cast for the jsonb column (the@groombook/typesMedicalAlerthas an optional server-generatedid). The other 3 fields flow through...rest.Notes
src/routes/pets.ts(+26/−2). Branch was rebrought current withdev(was 26 commits behind).77a6ad5(GRO-2310) — PASS.apps/api/src/routes/pets.tsconfirmed.UAT Playbook
No update needed —
UAT_PLAYBOOK.md§3 already documents these via TC-API-3.8 → TC-API-3.15 (create/update with extended fields + all boundary rejections).Refs: GRO-2172, GRO-1472, GRO-1178
cc @cpfarhood
createPetSchema in src/routes/pets.ts was missing temperamentScore, temperamentFlags, medicalAlerts, and preferredCuts. Migrations 0034/0036 and seed data populate them, but POST/PATCH silently dropped the fields because Zod validation rejected them. GET worked because seed bypassed the schema. This is the regression originally reported as GRO-1472 and blocks the GRO-1178 extended-profile feature rollout (api/#39). Mirrors the field shape that already lives in apps/api/src/routes/pets.ts (legacy duplicate) and the test expectations in apps/api/src/__tests__/petsExtendedFields.test.ts: - temperamentScore: int 1–5 - temperamentFlags: string[] (max 20, item max 100) - medicalAlerts: { type, description, severity: low|medium|high }[] (max 50) - preferredCuts: string[] (max 20, item max 200) updatePetSchema inherits from createPetSchema.partial().omit({ clientId }) so no separate change is needed there. POST/PATCH handlers now forward medicalAlerts through to the insert/update with a localized cast — the @groombook/types MedicalAlert includes a server-generated id that is not part of the API request shape, and the jsonb column is schemaless at runtime. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>