Skip to content

refactor: upgrade Zod to v4#264

Open
314systems wants to merge 1 commit into
pnpm:masterfrom
314systems:zod
Open

refactor: upgrade Zod to v4#264
314systems wants to merge 1 commit into
pnpm:masterfrom
314systems:zod

Conversation

@314systems

@314systems 314systems commented Jun 1, 2026

Copy link
Copy Markdown

Overview

Upgraded Zod from v3 to v4 and refactored run-install.ts to utilize the new APIs for cleaner flow and better error formatting.

Changes

  • Dependency Upgrade: Bumped zod to ^4.4.3.
  • Flow Refactoring: Replaced try/catch block containing .parse() with .safeParse() in parseRunInstall for more idiomatic TypeScript validation.
  • Log Formatting Improvement: Fixed a bug where validation errors printed as [object Object] in the logs by adopting Zod v4's new z.prettifyError() function.
  • Code Cleanup: Removed the unused named import ZodError and the internal RunInstallInput type.

Verification

  • Verified that type-checking (tsc --noEmit) passes successfully.
  • Ran pnpm run build to ensure the bundle builds without issues.

Summary by CodeRabbit

  • Dependencies

    • Upgraded zod to version 4.4.3.
  • Improvements

    • Improved handling of invalid install inputs with clearer, formatted validation errors and more detailed diagnostics.
    • Kept install input normalization behavior consistent (e.g., converting single values/booleans into the expected internal array form).

@314systems
314systems requested a review from zkochan as a code owner June 1, 2026 01:08
@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a421ff06-9a91-4e5d-a985-8e04ee2126c0

📥 Commits

Reviewing files that changed from the base of the PR and between 24d83a9 and 2f88ccb.

⛔ Files ignored due to path filters (2)
  • dist/index.js is excluded by !**/dist/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • package.json
  • src/inputs/run-install.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • package.json
  • src/inputs/run-install.ts

📝 Walkthrough

Walkthrough

This PR upgrades the Zod validation library from v3 to v4 and refactors src/inputs/run-install.ts to use Zod v4's API conventions: namespace imports, safeParse with success branching, and error reporting via z.prettifyError().

Changes

Zod v4 Upgrade and Code Migration

Layer / File(s) Summary
Zod v4 Dependency Update
package.json
Zod dependency is updated from ^3.22.4 to ^4.4.3.
Zod v4 API Migration in run-install.ts
src/inputs/run-install.ts
Import statement switches to namespace import (* as z); parseRunInstall replaces parse() with safeParse and checks result.success, using z.prettifyError() for validation failures; the same normalization rules for null, boolean true, arrays, and single objects are preserved.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 From v3 bounds to v4 shores, namespace imports we adore,
safeParse shields where errors once roared, prettified and stored,
Zod's newest embrace makes validation just right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: upgrade Zod to v4' accurately describes the main change: upgrading Zod from v3 to v4, which is reflected in the package.json version bump and corresponding refactors in src/inputs/run-install.ts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Review Summary by Qodo

Upgrade Zod to v4 with validation refactoring

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Upgraded Zod dependency from v3 to v4 for improved validation APIs
• Refactored validation logic to use safeParse() instead of try/catch
• Fixed validation error formatting using Zod v4's prettifyError() function
• Removed unused ZodError import and RunInstallInput type definition
Diagram
flowchart LR
  A["Zod v3.24.1"] -- "upgrade" --> B["Zod v4.4.3"]
  C["try/catch + parse()"] -- "refactor" --> D["safeParse()"]
  E["Error formatting bug"] -- "fix" --> F["prettifyError()"]
  G["Unused imports/types"] -- "cleanup" --> H["Removed"]

Loading

Grey Divider

File Changes

1. package.json Dependencies +1/-1

Update Zod dependency version

• Updated zod dependency from ^3.22.4 to ^4.4.3

package.json


2. pnpm-lock.yaml Dependencies +6/-5

Lock file updates for Zod v4

• Updated zod package resolution from 3.24.1 to 4.4.3
• Added deprecation notice for uuid@8.3.2

pnpm-lock.yaml


3. src/inputs/run-install.ts ✨ Enhancement +10/-15

Refactor validation to use Zod v4 APIs

• Changed import from named imports to namespace import (import * as z from 'zod')
• Replaced try/catch block with safeParse() for cleaner validation flow
• Implemented z.prettifyError() for proper error message formatting
• Removed unused ZodError import and RunInstallInput type export
• Refactored result handling to use destructured data property

src/inputs/run-install.ts


View more (1)
4. dist/index.js Miscellaneous +229/-165

Compiled distribution bundle update

• Compiled output reflecting the source code changes in run-install.ts

dist/index.js


Grey Divider

Qodo Logo

Signed-off-by: Akihiro Nagai <77012577+314systems@users.noreply.github.com>
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