Repository navigation
Description
Found while investigating why #870 (the backend Dependabot group) is red. zod 4.1.13 → 4.6.5 is the sole cause and the failure is a real behaviour change, not a test artifact.
Evidence that it is zod alone
On #870's branch, with every other bump in the group applied:
| zod | profile-employment-left.test.tsx |
|---|---|
| 4.6.5 (the bump) | 31 passed, 9 failed |
| 4.1.13 (pinned back, nothing else changed) | 40 passed, 0 failed |
What changed
zod 4.6 added a guard that 4.1 did not have. Reduced to the two lines that matter:
const schema = z.object({ /* … */ }).partial().superRefine(/* … */)
schema.pick({ drivers_license_classes: true })zod 4.1.13 -> works; returns { drivers_license_classes: ['Class A'] }
zod 4.6.5 -> Error: .pick() cannot be used on object schemas containing refinements
4.1 quietly allowed the pick and dropped the refinement. 4.6 refuses.
Why that is worse than a failing test
profileEmploymentInputSchema ends in .superRefine(...) (consolidated.ts:285-329), and five employment cards .pick() from it inside their save handler:
EmploymentDriversLicenseCard.tsx:41EmploymentMilitaryCard.tsx:39EmploymentAvailabilityCard.tsx:39EmploymentLocationsCard.tsx:35EmploymentHourlyRateCard.tsx:36
Each one is shaped like this:
const result = profileEmploymentInputSchema
.pick({ drivers_license_classes: true })
.safeParse({ drivers_license_classes: next })
if (!result.success) return // <- silentUnder 4.6 the .pick() throws before safeParse is reached, on every interaction, inside an event handler. The user ticks a licence class and nothing is saved. And the existing if (!result.success) return means the non-throwing failure mode is equally silent — no toast, no log, no console warning. That is the whole Work Preferences / Work Qualifications form: hourly rate, work locations, driver's licence, military status, availability.
That is exactly what the test output shows — Number of calls: 0, or a save recorded for the boolean residency toggle and then nothing for the array field:
- ObjectContaining { "drivers_license_classes": ["Class A"] }
+ { "us_resident": true }
This is latent, not live. On main zod is 4.1.13, so the form works today. The bump is what would introduce it — which is the good news, and the reason #870 must not be merged as-is.
The fix
Keep the unrefined object addressable and attach the refinement after it, so callers that need one field pick from the base while routers keep validating against the refined schema. Verified against 4.6.5:
pick(base) -> true {"drivers_license_classes":["Class A"]}
refine still fires -> true "Please select a travel distance"
valid full parse -> true
- Split
consolidated.tsintoprofileEmploymentBaseSchema(thez.object({…}).partial()) andprofileEmploymentInputSchema = profileEmploymentBaseSchema.superRefine(…), exporting both. - Point the five cards'
.pick()at the base schema. - Give the
if (!result.success) returnbranches alogger.warnat minimum — a validation failure that discards a user's input must not be silent. This is the part that turned a library guard into an invisible data-loss bug. - A test asserting
.pick()on whatever the cards import does not throw, so the next refinement added to that schema fails loudly in CI instead of in the browser.
Checked and clear
The other two .pick() call sites are on plain z.object()s with no refinements and are unaffected: teamCreateBaseSchema (TeamForm.tsx:60) and adminCheckTypeSchema (background-checks.router.ts:193, background-checks-admin.ts:57).
Sequencing
#870 is also blocked by #907 (the Expo gate, fixed in #908). Once that clears, this still stands. Suggested order: land this fix, then let zod 4.6 in — either by re-running #870 or by splitting zod out so the posthog and tRPC bumps are not held behind it.
Activity
thinkclay commentedon Sep 25, 2026
Fix is up in #912, with the acceptance list covered:
profileEmploymentBaseSchema(the plain.partial()object) andprofileEmploymentInputSchema(base + the travel rule). Routers keep the refined one.if (!result.success) returnnow logs the zod issues first.employment-schema-pick.test.tsfails if a refinement is ever attached to the schema the cards import.Proved against the real version rather than reasoning about it — temporarily moved the catalog pin to 4.6.5, ran, then reverted:
fix(profile): pick employment fields from an unrefined schema (#910) (#…
chore(supabase): delete the dead duplicate of consolidated.ts, and ru…