Skip to content

chore: migrate to zod v4 and refactor schema conversion#117

Open
k35o wants to merge 4 commits into
vercel:mainfrom
k35o:upgrade-zod
Open

chore: migrate to zod v4 and refactor schema conversion#117
k35o wants to merge 4 commits into
vercel:mainfrom
k35o:upgrade-zod

Conversation

@k35o

@k35o k35o commented Jan 23, 2026

Copy link
Copy Markdown

Upgrades Zod from v3 (3.25.76) to v4 (4.3.6) and updates code to use the new v4 APIs.

Changes

Dependencies:

  • zod: 3.25.76 → 4.3.6
  • @anthropic-ai/claude-agent-sdk: 0.1.15 → 0.2.12

Code changes:

  • Replace manual zodSchemaToJsonSchema implementation with Zod v4's built-in z.toJSONSchema() method
  • Replace deprecated .isOptional() with safeParse(undefined).success for optional parameter detection
  • Simplify type definitions and reduce code complexity

Migration Details

Zod v4 deprecated the .isOptional() method. The new approach uses safeParse(undefined) to detect optional parameters:

  • Required parameters: safeParse(undefined).success === false
  • Optional parameters: safeParse(undefined).success === true

This change has been tested and behaves identically to the v3 implementation.

Benefits

  • Cleaner code: Leveraging Zod's native JSON Schema conversion.
  • Future-proof: Aligns with Zod v4 standards and avoids upcoming v3 deprecation.
  • Reduced maintenance: Removed ~40 lines of manual schema conversion logic.

@socket-security

socket-security Bot commented Jan 23, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​anthropic-ai/​claude-agent-sdk@​0.2.141741008710070
Updatednpm/​zod@​3.25.76 ⏵ 4.3.610010010093100

View full report

k35o added a commit to k35o/next-devtools-mcp that referenced this pull request Jan 23, 2026
Downgrade @anthropic-ai/claude-agent-sdk from 0.2.17 to 0.2.12 to improve
Supply Chain Security score (from 73 to potentially higher based on Socket
Security analysis in PR vercel#117).
@k35o k35o force-pushed the upgrade-zod branch 2 times, most recently from 016558e to 066b248 Compare June 15, 2026 13:31
k35o added 4 commits June 15, 2026 22:34
- zod: 3.25.76 -> 4.3.6
- @anthropic-ai/claude-agent-sdk: 0.1.15 -> 0.2.17
- Replace manual zodSchemaToJsonSchema implementation with Zod v4's built-in z.toJSONSchema()
- Replace deprecated .isOptional() with safeParse(undefined) for optional parameter detection
Downgrade @anthropic-ai/claude-agent-sdk from 0.2.17 to 0.2.12 to improve
Supply Chain Security score (from 73 to potentially higher based on Socket
Security analysis in PR vercel#117).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant