fix: restore admin form validation under zod v4 (@hookform/resolvers v5)#16128
fix: restore admin form validation under zod v4 (@hookform/resolvers v5)#16128shanikonimbo wants to merge 2 commits into
Conversation
@hookform/resolvers@3.x reads the removed ZodError.errors property, so under zod v4 (Medusa's internal zod since 2.14) validation errors are silently dropped instead of populating react-hook-form's formState.errors — no inline field errors render on invalid submit. Bump @hookform/resolvers to ^5.2.2 (auto-detects zod v3/v4, reads .issues) and react-hook-form to ^7.55.0 (peer requirement of resolvers v5) in the dashboard and draft-order plugin, regenerate the lockfile, and add a changeset. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: ae6c1c7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 79 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thanks for the contribution! Initial automated review looks good. Dependency bump: @hookform/resolvers 3.4.2 -> 5.4.0 and react-hook-form 7.49.1 -> 7.82.0 in dashboard and draft-order. Root cause verified: dashboard declares zod 4.2.0, and resolvers 3.x reads the removed ZodError.errors; resolvers 5.1.0+ supports zod v4 (still zod v3 compat) and maps validation errors correctly. RHF jump is in-range 7.x (adds React 19 peer). Supply chain clean: genuine packages, one legit new transitive dep @standard-schema/utils, no new lifecycle scripts, lockfile consistent. Areas to test: dashboard typecheck/build and admin form validation, since resolvers 3->5 is a major Triggered by: new PR opened |
shahednasser
left a comment
There was a problem hiding this comment.
Thank you for your contribution @shanikonimbo !
Have you tried running the build command? The @medusajs/dashboard package has build errors following this update. Can you fix them?
Under @hookform/resolvers v5 the zodResolver is typed on the schema's zod v4 output type, which no longer matches react-hook-form's field value generics in a few generic form wrappers. This restores a clean typecheck/build: - useExtendableForm: default TTransformedValues to the schema's inferred type (v5's rhf peer >=7.55 otherwise resolves handleSubmit's data to `undefined`), and cast the useForm options to keep the declared value types over the extended (base + additional_data) schema. - tiered-price-form / property-labels: cast the generically-typed zodResolver call to the form's Resolver type. - data-grid-root: cast the memoized control to Control<any> for the context value. - order-balance-settlement: guard optional nested field value access. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What
Upgrades
@hookform/resolvers(3.4.2 →^5.2.2) andreact-hook-form(7.49.1 →^7.55.0) in@medusajs/dashboardand the@medusajs/draft-orderplugin — the only two packages that pin them — plus a regeneratedyarn.lockand a changeset.Why
Medusa's internal
zodmoved to v4 in 2.14. In zod v4 aZodErrorexposes only.issues— the old.errorsalias was removed.@hookform/resolvers@3.xguards onerror.errors != null, which is now always false, so theZodErroris re-thrown instead of being mapped intoreact-hook-form'sformState.errors. Result: admin form validation errors are silently dropped — no inline field errors render on an invalid submit. Purely client-side (the backend reads.issuesand is unaffected).How
@hookform/resolvers@5detects the schema shape (zod v4 schemas expose_zod) and readserror.issues, so it maps validation errors correctly. resolvers v5 declaresreact-hook-form@^7.55.0as a peer, so both must be bumped together. The lockfile was regenerated withyarn install --mode=update-lockfile(resolvers → 5.4.0, react-hook-form → 7.82.0; no other entries affected).Testing
3.4.2drops errors ❌ vs5.2.2captures them ✅) are documented in [Bug]: Admin dashboard client-side validation does not render — @medusajs/dashboard pins zod@4 with @hookform/resolvers@3.4.2 (no zod v4 support) #15876.Additional context
yarn.lockupdate flagged by CI).