• Will Chen's avatar
    Migrate to Zod v4 (#2415) · f0431145
    Will Chen 提交于
    ## Summary
    - Upgraded zod package from ^3.25.76 to ^4.3.6
    - Updated z.record() calls to use two arguments (key schema, value
    schema) as required by Zod v4
    - Changed ZodError.errors to ZodError.issues (API rename in v4)
    - Fixed type inference issues with complex generics in
    createStreamClient
    
    ## Test plan
    - [x] TypeScript type-checking passes (`npm run ts`)
    - [x] Linting passes (`npm run lint`)
    - [x] Unit tests pass (661/661 tests)
    - [x] E2E tests pass (195/213 tests - 12 failures are pre-existing flaky
    tests unrelated to Zod)
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    <!-- devin-review-badge-begin -->
    
    ---
    
    <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2415">
      <picture>
    <source media="(prefers-color-scheme: dark)"
    srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
    <img
    src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1"
    alt="Open with Devin">
      </picture>
    </a>
    <!-- devin-review-badge-end -->
    
    <!-- CURSOR_SUMMARY -->
    ---
    
    > [!NOTE]
    > **Medium Risk**
    > Medium risk because this upgrades a core validation library and
    adjusts IPC schema/handler typings; behavioral changes in Zod
    parsing/record typing could surface at runtime if any edge cases differ.
    > 
    > **Overview**
    > Upgrades `zod` from v3 to v4 (and bumps `zod-to-json-schema`),
    updating the lockfile and keeping a nested v3 `zod` for
    `@modelcontextprotocol/sdk`.
    > 
    > Updates IPC validation code to match Zod v4: switches
    `ZodError.errors` to `ZodError.issues`, updates all `z.record(...)`
    usages to the new `z.record(keySchema, valueSchema)` signature, and
    applies a few TypeScript workarounds (notably in `createStreamClient`
    key handling and `registerTypedHandlers` casting) to avoid inference
    breaks under v4.
    > 
    > <sup>Written by [Cursor
    Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
    2e1becc1b56c343ee969e86de2146e36d255e7ae. This will update automatically
    on new commits. Configure
    [here](https://cursor.com/dashboard?tab=bugbot).</sup>
    <!-- /CURSOR_SUMMARY -->
    
    <!-- This is an auto-generated description by cubic. -->
    ---
    ## Summary by cubic
    Migrated the codebase to Zod v4. Updated record schemas and error
    handling, plus small type fixes in IPC; no runtime changes expected.
    
    - **Dependencies**
      - Upgraded zod to ^4.3.6.
      - Bumped zod-to-json-schema to 3.25.1.
    
    - **Refactors**
      - Replaced z.record(value) with z.record(key, value) across schemas.
      - Switched ZodError.errors to ZodError.issues in handlers.
    - Improved createStreamClient key typing (string | number) and used
    safer Record<string, unknown> casts.
    - Added an explicit type assertion in registerTypedHandlers for handler
    registration.
    
    <sup>Written for commit 15413b80916c6816f7c24a59815663f502ac9e3d.
    Summary will update on new commits.</sup>
    
    <!-- End of auto-generated description by cubic. -->
    
    ---------
    Co-authored-by: 's avatarClaude Opus 4.5 <noreply@anthropic.com>
    Co-authored-by: 's avatarclaude[bot] <41898282+claude[bot]@users.noreply.github.com>
    f0431145