Repository navigation
fix(deps): bump zod to 4.6.7 and @hookform/resolvers to 5.9.2 - #339
Conversation
GHSA-mrhx-c7xc-m3w5 (CVE-2023-54404, high) covers zod `<4.6.6`, which includes every 3.x — 3.25.76 is the last 3.x published, so there is no patch on our line and the only fix is the major. The two bumps are one change, not two riding together. Under zod 4 alone, `@hookform/resolvers@3`'s zod adapter reads `ZodError.errors`, which v4 renamed to `issues`, so it rethrows instead of converting: the unit lane turned up four unhandled ZodError rejections out of the report form, and both public forms would throw on validation rather than mark a field invalid. Reverting one has to revert the other. Three API changes the majors forced, each checked against 3.25.76 for behaviour: - `z.record` needs its key schema in v4, so `TranslationBundleSchema` passes `z.string()`. - `z.record` over an enum key now requires EVERY member. The registration answers are a subset of the event's enabled questions, so they move to `z.partialRecord`, which parses the same inputs 3.x did — including rejecting a key outside the contract. - `zodResolver` now types the form on the schema's INPUT, so `RegistrationForm` takes react-hook-form's three generics and `reportValuesSchema` keeps its value types narrow through the shape cast. Checked identical across 3.25.76 and 4.6.7: the email and name regexes, `z.coerce.date()`, `.passthrough()`, `.default([])`, `.catch(null)`, unknown-key stripping and `.nonempty()`. ⚠ The 4.6.6 fix short-circuits only an array carrying `max` or an exact `length`. An unconstrained array still accumulates one issue per failing element, measured at 200,000 issues on both versions, and every array schema here is unconstrained. So the bump clears the advisory; it does not change what this code does. Bounding the feed schemas is what would, and that needs a decision about what happens to a page over the bound. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjV2RH3s8vkHeuM5wJ5
zod 4's classic API is bigger than 3.25.76's in this graph, and the schemas are eager because every fetcher parses through one, so the security bump beside this commit put both graphs over the 318 KiB budget: standalone 324.1, embed 325.9, measured uncredentialed as CI reads them. 330 clears each graph's credentialed figure and leaves both CI numbers inside the slack window, so the ratchet rule still holds. Separate from the bump on purpose: the bytes are a cost on every host page, and refusing them is a decision that can be taken without reverting the advisory fix. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjV2RH3s8vkHeuM5wJ5
The rule still holds and the reason behind it moved: `ZodError.errors`, which once matched `RefusalBodySchema` exactly, is `issues` in zod 4, so the collision the ⚠ warned about closed by luck rather than by design. Keeping the parse outside the `try` is what makes the refusal path unable to see a parse failure at all, so the placement is the rule and the shape never was. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjV2RH3s8vkHeuM5wJ5
`submissionData` spread `...data.questions` last, so a question whose CMS name was `name` or `locale` would have replaced the registrant's name or the language the confirmation is sent in. Nothing collides today — the four names the schema admits are `experience`, `referral`, `aspirations` and `questions`, and the schema refuses anything else — so this is a latent hole rather than a live one, and it closes by reordering. `sendReport` already writes its own context keys last for exactly this reason, which `docs/rules/data-layer.md` states as a rule. The two intakes now agree. Found while reviewing the zod 4 bump beside this commit, in a file that branch already touches. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjV2RH3s8vkHeuM5wJ5
sydevs-bot
left a comment
There was a problem hiding this comment.
1 question for the reviewer, one per thread.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Deploying sahajatlas with
|
| Latest commit: |
19e64a5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a3f34494.sahajatlas.pages.dev |
| Branch Preview URL: | https://claude-fix-deps-zod.sahajatlas.pages.dev |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
sahajatlas-design | 93d4ea0 | Oct 27 2026, 07:15 PM |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is no bigger than the advisory. Every type change is forced by the major, and I checked each against the installed 4.6.7 rather than the body's account. The joined ordering change sits in a file the bump already rewrites and is named in ## Summary, so it is not smuggled scope. The budget raise already carries its own question thread, which I have not duplicated.
Findings
consider— the key-ordering guard has no spec, so a later edit can reverse it green.src/config/api/mutate.ts:194consider— a fourth forced migration the## Change outlineomits.src/types/translations.ts:22
What was checked
Probed 4.6.7 directly: partialRecord takes a subset and still refuses an unknown key, while record over an enum demands every member. ZodError.errors is genuinely gone, so RefusalBodySchema no longer matches a thrown error though it still matches { errors: issues } — both prose corrections are accurate. too_big survives as an issue code, so errorCopy's textarea branch still picks the max copy, and the v5 resolver's zod-4 path still sets type from issue.code.
Read whole: report-form.ts, registration.ts, RegistrationForm.tsx, ReportIssueForm.tsx, mutate.ts, check-bundle-size.mjs. sendReport does spread answers first, and experience/referral/aspirations/questions collide with neither name nor locale.
CHANGELOG.md records origins, parameters and visible behaviour, and excludes internal work, so the bytes earn no entry. Preview deployed green.
Checked and left alone: an unrecognised question key now raises unrecognized_keys at questions, not at the key, so errors.questions?.[q]?.message renders nothing. It needs a draft outliving a CMS rename.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The reorder in the commit before this one had no spec holding it. All 28 existing `createRegistration` cases pass under either spread order, because none of the four question names the schema admits collides with `name` or `locale` — so a later edit could restore the old order with the lane green, and the collision would first become reachable when SahajCloud renames a question, which is exactly when nobody is reading that line. The new case casts `questions` to carry `name` and `locale`, which the schema otherwise refuses, and asserts the registrant's name and the resolved locale survive. Reversing the spread in `mutate.ts` fails this case and only this case. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYGKXqdVCbtn2j5vX5
|
Both critic threads adopted. Pushed
The 330 KiB budget question stays open. It waits on a letter. Branch already sat on Gate: lint, typecheck and 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Approved, but this thread still waits on you, and the ruleset will not merge until it is resolved: #339 (comment). Reply there, or resolve it. 🤖 sydevs dispatcher |
#339's zod 4 bump landed on main and touched the same four files this branch does. Every hunk kept both sides. - `types/registration.ts`: `z.partialRecord` for the answers (zod 4 requires every member of an enum-keyed `record`) plus this branch's `subscribe` field, and main's `RegistrationInput` export. - `config/api/mutate.ts`: main reordered `submissionData` so the answers spread FIRST and our own keys are written last, which `docs/rules/data-layer.md` states as a rule. `subscribe` is one of our own keys, so it joins `name` and `locale` after the spread rather than before it — a question named `subscribe` can no longer open a mailing-list row. - `config/api/mutate.ts`, `sendReport`: this branch's refactor to the shared `postUserSubmission` wins over main's inline body, and main's correction to the stale zod-3 `ZodError.errors` claim is carried into that helper's JSDoc, where the inline comment had moved. - `RegistrationForm.tsx`: `hasMailingList` plus main's three react-hook-form generics over `RegistrationInput`. - `mutate.test.ts`: both new cases kept. Lean gate: lint, typecheck, 169 files / 1943 tests, all green. `pnpm size` is left to CI; main raised the budget to 330 KiB in the same PR, and this branch's +0.4 KiB sits inside it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYRGYFVBUjDNo9mmJq
Summary
@hookform/resolvers5.9.2 rides along because zod 4 alone breaks both public forms.nameandlocaleare now written after the answers,so a question named either cannot replace them. Found while reviewing the bump, and
pinned by a spec case of its own.
Change outline
The bump is four API migrations, not a version string. Each was checked against 3.25.76
rather than inferred from the changelog.
Types — the registration form holds the schema's INPUT
zodResolvernow types the form on what the controls hold, so the coercion's two sidesneed separate names.
handleSubmitis the only place aDateexists.Types — the report form's shape keeps its value types
The dynamic schema is built from authored blocks, so its shape is a
Record. Widened toZodRawShapethe object's input becomesunknownper key, and the resolver stops matchingReportValues. No validation rule changes.Types —
z.recordnames its key schemav4 dropped the single-argument form. This is the fourth forced migration, and the only one
outside the two forms: the translation bundle is a recursive tree, so the key type is stated
where the recursion is declared. What it accepts does not change — a tree of strings, any
depth, no key list.
Behaviour — what the advisory fix does, and does not, change
Measured on a 200,000-element array of failing values, 3.25.76 against 4.6.7:
4.6.6 short-circuits a
maxor exactlengthonly. Every array schema here isunconstrained, so the bump clears the advisory without changing what this code does.
Behaviour — the registration's own keys go last
Found reviewing this branch, in a file it already touches. Nothing collides today, so this
closes a latent hole rather than a live one.
createRegistration(eventId, data, token) src/config/api/mutate.ts submissionData({ + …data.questions # the answers first name: data.name locale: activeLocale() # ours last, as sendReport already does - …data.questions })A spec case now holds that order. The 28 cases that existed pass under either spread
direction, because none of the four admitted question names collides, so the collision is
reachable only through a cast:
Preview
This change has no visual surface: the forms render identically and the diff is a
dependency bump plus type names. The browser pass under Manual verification is what
covers it.
Test results
test:run(152 files, 1794 tests, 0 errors)RegistrationForm,ReportIssueForm(both files),mutatepnpm size: ✓ on the bump's own push; CI runs both again hereThree things worth knowing about the gate on this branch:
ZodError rejections out of
ReportIssueForm.submit.test.tsx. That is what identified theresolver as part of the fix rather than a nice-to-have.
src/types/registration.test.tsalready pins thequestionsbehaviour. SwappingpartialRecordback torecordfails two of its nine cases, so the subset contract iscovered by specs that existed before this branch.
mutate.tsreddens thatone case and no other.
Manual verification
The resolver change is form validation, and the unit lane sees it through jsdom only.
field should mark invalid and read its error, not throw.
startingAtmust be an ISO string, so thecoercion ran.
valid one.
submissionDatashould still carrynameandlocalealongside theanswers, in any order.
Notes for reviewer
@hookform/resolvers@3's zod adapter readsZodError.errors, which v4 renamedissues, so it rethrows instead of converting tofield errors. Reverting either one has to revert both.
z.partialRecordis not a loosening. It rejects a key outsideEVENT_REGISTRATION_QUESTIONSexactly as 3.x'sz.recorddid — the keys are spread intosubmissionData, so that mattered. v4'sz.recordover an enum key additionally requiresevery member, which an event enabling a subset of questions never sends.
z.coerce.date(),.passthrough(),.default([]),.catch(null), unknown-key stripping,.nonempty()./security-reviewreported no findings, and it is the pass the trigger paths(
package.json,pnpm-lock.yaml,src/config/api/) require. It read the resolver's ownzod.mjsand react-hook-form'shandleSubmit, drove the realuseFormthrough a jsdomsubmit, and read
@standard-schema/utils's whole dist. The ordering fix above is its onenon-security observation, routed as a commit. The second lens was a line-by-line read of
the branch diff by this session — not a
/code-reviewfan-out, since the functional diffis four lines and two type names.
partialRecordagainst the installed 4.6.7 rather than the changelog: a key outside theenum is still pushed as
unrecognized_keysand never written into the parsed value, sothe ordering guard stays defence-in-depth. It also re-checked
SafeUrlSchemaand theemail schema side by side on zod 3 and 4 — identical verdicts on
javascript:,java\nscript:,data:,//evil.comand CRLF header-injection payloads.@standard-schema/[email protected]is the one new transitive dependency, pulled by theresolver. Nothing imports it from the
zodsubpath either call site uses.RegistrationFieldsPropswithControl<Registration>as context and addssubscribetoRegistrationSchemaon theline below the one this changes, so the two conflict textually in
src/types/registration.tsandRegistrationForm.tsx. Whichever lands second owes thethree-generic treatment to the other's form code. Landing this one first keeps that work
in one place — feat(widget): submit or correct a class, and opt into a mailing list #318 has the larger diff.
Detail
Why there is no 3.x fix. The advisory range is
<4.6.6, which includes every 3.x bysemver, and 3.25.76 is the last 3.x published — the 3.26 line never left canary. So the
major is the only patched version, which is why this is an audit PR and not a Dependabot
one.
Reachability here is narrow, which is context for the question about the bytes rather
than an argument for skipping the bump. Every array schema parses a SahajCloud page, and
SahajCloud caps a client read at 2000 rows (
MAX_CLIENT_LIMIT), so the accumulation anattacker would need is bounded by the producer. The code also runs in the visitor's own
browser, so the memory exhausted is their tab's.
What a real mitigation would look like: a
maxon the feed and region array schemas,which would make the 4.6.6 short-circuit apply. Not built here, and deliberately not a
second question thread — it needs a decision about what a page over the bound should do,
and that decision should not hold up a security bump. Recorded so it is not lost.
Not stale, checked:
docs/embedding.mdandCHANGELOG.mdtake nothing. No origin, CSP,Permissions-Policy, attribute, sizing or URL-shape change, and the changelog is explicitly
for what a host observes.
docs/testing.mdanddocs/architecture.mdmention zod onlyversion-agnostically.
docs/rules/data-layer.md's ⚠ on theZodErrorshape did go stale,and is corrected in its own commit. Nothing in
docs/states a test count.One cosmetic dead path, left alone twice now.
errors.questions?.[question]?.messagein
RegistrationFieldscannot render anunrecognized_keyserror: zod reports that issueat path
questions, notquestions.<key>, so the indexed read isundefined. Submit isstill blocked correctly, and the case is unreachable while the rendered question list comes
off the same enum. It needs a draft outliving a CMS rename to matter.
Generated by Claude Code