Skip to content

fix(deps): bump zod to 4.6.7 and @hookform/resolvers to 5.9.2 - #339

Merged
sydevs-bot merged 5 commits into
mainfrom
claude/fix-deps-zod
Oct 28, 2026
Merged

sydevs-bot merged 5 commits into
mainfrom
claude/fix-deps-zod

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Clears GHSA-mrhx-c7xc-m3w5 (high, runtime) by taking zod 4.6.7; no 3.x patch exists.
  • @hookform/resolvers 5.9.2 rides along because zod 4 alone breaks both public forms.
  • Raises the eager-payload budget to 330 KiB, which zod 4 costs us. One question on that.
  • Joined: the registration's own name and locale are 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

zodResolver now types the form on what the controls hold, so the coercion's two sides
need separate names. handleSubmit is the only place a Date exists.

 RegistrationSchema                                src/types/registration.ts
   startingAt  z.coerce.date()                     # the control holds an ISO string
-  questions   z.record(QuestionName, string)      # v4: requires EVERY member
+  questions   z.partialRecord(QuestionName, string)
   Registration      = z.infer<…>                  # what a submission is
+  RegistrationInput = z.input<…>                  # what the fields hold

 RegistrationForm                                  src/components/organisms/RegistrationForm/
-  useForm<Registration>
+  useForm<RegistrationInput, unknown, Registration>
   handleSubmit(data)                               # data is Registration — coercion already ran
   RegistrationFieldsProps
-    register / control / errors  …<Registration>
+    register / control / errors  …<RegistrationInput>

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 to
ZodRawShape the object's input becomes unknown per key, and the resolver stops matching
ReportValues. No validation rule changes.

 reportValuesSchema(fields)                        src/lib/report-form.ts
   fromEntries(fields.flatMap(…))
-    [string, z.ZodTypeAny][]
+    [string, z.ZodType<string | boolean, string | boolean>][]
-    as z.ZodRawShape
+    as Record<string, z.ZodType<string | boolean, string | boolean>>
   → z.object(…)                                   # output stays ReportValues

Types — z.record names its key schema

v4 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.

 TranslationBundleSchema                           src/types/translations.ts
-  z.record(z.union([string, TranslationBundleSchema]))
+  z.record(z.string(), z.union([string, TranslationBundleSchema]))

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:

 z.array(z.number())              v3  200,000 issues    v4  200,000 issues
 z.array(z.number()).max(10)      v3  200,001 issues    v4        1 issue
 z.array(z.number()).length(10)   v3  200,001 issues    v4        1 issue
 z.array(z.number()).min(1)       v3  200,000 issues    v4  200,000 issues

4.6.6 short-circuits a max or exact length only. Every array schema here is
unconstrained, so the bump clears the advisory without changing what this code does.

 eager payload, gzipped, uncredentialed            scripts/check-bundle-size.mjs
-  standalone / embed budget   318 KiB
+  standalone / embed budget   330 KiB             # measured 324.1 / 325.9

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:

 createRegistration                                src/config/api/mutate.test.ts
+  questions: { name, locale } as Registration['questions']
+    → name stays 'Ada', locale stays 'fr'

Preview

  • App and Storybook — preview pending (no Cloudflare alias on this branch yet).

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

  • Lean gate: ✓ lint, typecheck, test:run (152 files, 1794 tests, 0 errors)
  • Targeted specs: 46 passed — RegistrationForm, ReportIssueForm (both files), mutate
  • Build and pnpm size: ✓ on the bump's own push; CI runs both again here

Three things worth knowing about the gate on this branch:

  • Before the resolver bump, the unit lane passed 1793 tests and reported 4 unhandled
    ZodError rejections out of ReportIssueForm.submit.test.tsx. That is what identified the
    resolver as part of the fix rather than a nice-to-have.
  • src/types/registration.test.ts already pins the questions behaviour. Swapping
    partialRecord back to record fails two of its nine cases, so the subset contract is
    covered by specs that existed before this branch.
  • The ordering case was watched failing: reversing the spread in mutate.ts reddens that
    one case and no other.

Manual verification

The resolver change is form validation, and the unit lane sees it through jsdom only.

  1. Open an event with registration enabled, pick a date, submit with a blank name — the
    field should mark invalid and read its error, not throw.
  2. Submit the same form filled in. The request's startingAt must be an ISO string, so the
    coercion ran.
  3. Open the report-issue form, trip a required field and an over-long value, then submit a
    valid one.
  4. The registration's submissionData should still carry name and locale alongside the
    answers, in any order.

Notes for reviewer

  • The two bumps are one change. Under zod 4, @hookform/resolvers@3's zod adapter reads
    ZodError.errors, which v4 renamed issues, so it rethrows instead of converting to
    field errors. Reverting either one has to revert both.
  • z.partialRecord is not a loosening. It rejects a key outside
    EVENT_REGISTRATION_QUESTIONS exactly as 3.x's z.record did — the keys are spread into
    submissionData, so that mattered. v4's z.record over an enum key additionally requires
    every member, which an event enabling a subset of questions never sends.
  • Checked identical across the two versions: the email and name regexes, z.coerce.date(),
    .passthrough(), .default([]), .catch(null), unknown-key stripping, .nonempty().
  • /security-review reported no findings, and it is the pass the trigger paths
    (package.json, pnpm-lock.yaml, src/config/api/) require. It read the resolver's own
    zod.mjs and react-hook-form's handleSubmit, drove the real useForm through a jsdom
    submit, and read @standard-schema/utils's whole dist. The ordering fix above is its one
    non-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-review fan-out, since the functional diff
    is four lines and two type names.
  • The pass ran again for the spec commit, and again found nothing. It settled
    partialRecord against the installed 4.6.7 rather than the changelog: a key outside the
    enum is still pushed as unrecognized_keys and never written into the parsed value, so
    the ordering guard stays defence-in-depth. It also re-checked SafeUrlSchema and the
    email schema side by side on zod 3 and 4 — identical verdicts on javascript:,
    java\nscript:, data:, //evil.com and CRLF header-injection payloads.
  • @standard-schema/[email protected] is the one new transitive dependency, pulled by the
    resolver. Nothing imports it from the zod subpath either call site uses.
  • Merge order matters against feat(widget): submit or correct a class, and opt into a mailing list #318. That branch carries RegistrationFieldsProps with
    Control<Registration> as context and adds subscribe to RegistrationSchema on the
    line below the one this changes, so the two conflict textually in
    src/types/registration.ts and RegistrationForm.tsx. Whichever lands second owes the
    three-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 by
semver, 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 an
attacker 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 max on 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.md and CHANGELOG.md take nothing. No origin, CSP,
Permissions-Policy, attribute, sizing or URL-shape change, and the changelog is explicitly
for what a host observes. docs/testing.md and docs/architecture.md mention zod only
version-agnostically. docs/rules/data-layer.md's ⚠ on the ZodError shape 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]?.message
in RegistrationFields cannot render an unrecognized_keys error: zod reports that issue
at path questions, not questions.<key>, so the indexed read is undefined. Submit is
still 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

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 sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 question for the reviewer, one per thread.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread scripts/check-bundle-size.mjs Resolved
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: 19e64a5
Status: ✅  Deploy successful!
Preview URL: https://a3f34494.sahajatlas.pages.dev
Branch Preview URL: https://claude-fix-deps-zod.sahajatlas.pages.dev

View logs

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
sahajatlas-design 93d4ea0 Oct 27 2026, 07:15 PM

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 27, 2026
@sydevs-bot

sydevs-bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 19:28Z address-review · attempt 1 · session · done
  • 19:28Z address-review · attempt 1 · session
  • 19:19Z review-pr · attempt 1 · session · done
  • 19:19Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 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:194
  • consider — a fourth forced migration the ## Change outline omits. 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

Comment thread src/config/api/mutate.ts Resolved
Comment thread src/types/translations.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 27, 2026
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
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Both critic threads adopted. Pushed 19e64a5.

The 330 KiB budget question stays open. It waits on a letter.

Branch already sat on main at 255fd2c, so no merge commit.

Gate: lint, typecheck and test:run green at 152 files, 1794 tests. /security-review re-ran over the branch and found nothing; the body records what it settled.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 27, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 27, 2026 19:47
@sydevs-bot
sydevs-bot requested a review from Ardnived October 27, 2026 19:47
@sydevs-bot
sydevs-bot enabled auto-merge October 27, 2026 19:47
@Ardnived Ardnived removed the awaiting label Oct 28, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

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

@sydevs-bot sydevs-bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Oct 28, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Oct 28, 2026
Merged via the queue into main with commit 6f91dd3 Oct 28, 2026
63 of 66 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-deps-zod branch October 28, 2026 16:27
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Oct 28, 2026
sydevs-bot pushed a commit that referenced this pull request Oct 28, 2026
#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants