-
-
Notifications
You must be signed in to change notification settings - Fork 11
chore: require zod4 or above #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Warning Rate limit exceeded@ymc9 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 13 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThis PR upgrades Zod from v3 to v4, updates validator type annotations from Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
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. Comment |
|
Claude finished @ymc9's task —— View job PR Review: Zod 4 MigrationReviewing this Zod 4 migration PR for code quality, bugs, performance, security, and test coverage. Todo List
Review SummaryThis PR successfully migrates ZenStack to require Zod 4+, with mostly automated test file regeneration accounting for the large line count changes (1639 additions, 2675 deletions). Critical Finding: Use of Deprecated
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR upgrades Zod from version 3.25.x to version 4.1.x and makes necessary code adjustments to accommodate breaking changes in Zod v4's API. The changes include:
- Updating package dependencies to use Zod ^4.1.0
- Modifying code to handle Zod v4 API changes (e.g.,
error?.issuesinstead oferror?.errors,options.errorinstead ofoptions.message) - Reformatting generated test schema files to use double quotes consistently
- Updating error message comparison to be case-insensitive
- Documenting the SWR plugin removal as a breaking change
Reviewed Changes
Copilot reviewed 27 out of 28 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Updated Zod version constraint from ^3.25.0 || ^4.0.0 to ^4.0.0 |
| packages/orm/src/client/crud/validator/utils.ts | Fixed Zod v4 API compatibility issues with error handling and validation |
| packages/orm/src/client/crud/validator/index.ts | Updated imports and type annotations for Zod v4 compatibility |
| packages/testtools/src/vitest-ext.ts | Made error message comparison case-insensitive |
| packages/*/package.json | Updated Zod dev dependencies to ^4.1.0 |
| tests/e2e/orm/schemas/*/schema.ts | Reformatted generated schema files with double quotes |
| BREAKINGCHANGES.md | Documented SWR plugin removal |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/orm/src/client/crud/validator/index.ts (1)
1375-1375: Consider updating to ZodType for consistency.Line 1375 still uses
z.ZodSchema, while similar declarations elsewhere in the file (lines 833, 1110, 1132, 1141, 1260) have been updated toZodType. For consistency with the Zod v4 migration, consider updating this as well.- let schema: z.ZodSchema = z.strictObject({ + let schema: ZodType = z.strictObject({
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (27)
BREAKINGCHANGES.md(1 hunks)package.json(1 hunks)packages/orm/package.json(1 hunks)packages/orm/src/client/crud/validator/index.ts(8 hunks)packages/orm/src/client/crud/validator/utils.ts(2 hunks)packages/server/package.json(1 hunks)packages/testtools/src/vitest-ext.ts(1 hunks)packages/zod/package.json(1 hunks)pnpm-workspace.yaml(1 hunks)tests/e2e/orm/schemas/basic/input.ts(1 hunks)tests/e2e/orm/schemas/basic/models.ts(1 hunks)tests/e2e/orm/schemas/basic/schema.ts(1 hunks)tests/e2e/orm/schemas/delegate/input.ts(1 hunks)tests/e2e/orm/schemas/delegate/models.ts(1 hunks)tests/e2e/orm/schemas/delegate/schema.ts(1 hunks)tests/e2e/orm/schemas/name-mapping/input.ts(1 hunks)tests/e2e/orm/schemas/name-mapping/models.ts(1 hunks)tests/e2e/orm/schemas/name-mapping/schema.ts(1 hunks)tests/e2e/orm/schemas/petstore/input.ts(1 hunks)tests/e2e/orm/schemas/petstore/models.ts(1 hunks)tests/e2e/orm/schemas/petstore/schema.ts(1 hunks)tests/e2e/orm/schemas/todo/input.ts(1 hunks)tests/e2e/orm/schemas/todo/models.ts(1 hunks)tests/e2e/orm/schemas/todo/schema.ts(1 hunks)tests/e2e/orm/schemas/typing/input.ts(1 hunks)tests/e2e/orm/schemas/typing/models.ts(1 hunks)tests/e2e/orm/schemas/typing/schema.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
{packages,samples,tests}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place packages only under
packages/,samples/, ortests/
Files:
packages/testtools/src/vitest-ext.tstests/e2e/orm/schemas/delegate/schema.tspackages/orm/package.jsontests/e2e/orm/schemas/petstore/schema.tstests/e2e/orm/schemas/petstore/input.tspackages/zod/package.jsontests/e2e/orm/schemas/todo/models.tstests/e2e/orm/schemas/basic/schema.tstests/e2e/orm/schemas/name-mapping/models.tspackages/orm/src/client/crud/validator/utils.tstests/e2e/orm/schemas/typing/input.tstests/e2e/orm/schemas/name-mapping/input.tstests/e2e/orm/schemas/typing/schema.tstests/e2e/orm/schemas/basic/input.tspackages/orm/src/client/crud/validator/index.tstests/e2e/orm/schemas/delegate/input.tstests/e2e/orm/schemas/todo/schema.tspackages/server/package.jsontests/e2e/orm/schemas/name-mapping/schema.tstests/e2e/orm/schemas/todo/input.tstests/e2e/orm/schemas/petstore/models.tstests/e2e/orm/schemas/basic/models.tstests/e2e/orm/schemas/delegate/models.tstests/e2e/orm/schemas/typing/models.ts
tests/e2e/**
📄 CodeRabbit inference engine (CLAUDE.md)
End-to-end tests must live under
tests/e2e/
Files:
tests/e2e/orm/schemas/delegate/schema.tstests/e2e/orm/schemas/petstore/schema.tstests/e2e/orm/schemas/petstore/input.tstests/e2e/orm/schemas/todo/models.tstests/e2e/orm/schemas/basic/schema.tstests/e2e/orm/schemas/name-mapping/models.tstests/e2e/orm/schemas/typing/input.tstests/e2e/orm/schemas/name-mapping/input.tstests/e2e/orm/schemas/typing/schema.tstests/e2e/orm/schemas/basic/input.tstests/e2e/orm/schemas/delegate/input.tstests/e2e/orm/schemas/todo/schema.tstests/e2e/orm/schemas/name-mapping/schema.tstests/e2e/orm/schemas/todo/input.tstests/e2e/orm/schemas/petstore/models.tstests/e2e/orm/schemas/basic/models.tstests/e2e/orm/schemas/delegate/models.tstests/e2e/orm/schemas/typing/models.ts
**/schema.ts
📄 CodeRabbit inference engine (CLAUDE.md)
The generated TypeScript schema should be named
schema.ts
Files:
tests/e2e/orm/schemas/delegate/schema.tstests/e2e/orm/schemas/petstore/schema.tstests/e2e/orm/schemas/basic/schema.tstests/e2e/orm/schemas/typing/schema.tstests/e2e/orm/schemas/todo/schema.tstests/e2e/orm/schemas/name-mapping/schema.ts
pnpm-workspace.yaml
📄 CodeRabbit inference engine (CLAUDE.md)
Use pnpm workspaces for the monorepo
Files:
pnpm-workspace.yaml
package.json
📄 CodeRabbit inference engine (CLAUDE.md)
Pin the repository package manager to
[email protected]via thepackageManagerfield
Files:
package.json
🧠 Learnings (5)
📚 Learning: 2025-09-04T12:38:14.150Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-04T12:38:14.150Z
Learning: Applies to **/schema.ts : The generated TypeScript schema should be named `schema.ts`
Applied to files:
tests/e2e/orm/schemas/delegate/schema.tstests/e2e/orm/schemas/petstore/schema.tstests/e2e/orm/schemas/petstore/input.tstests/e2e/orm/schemas/todo/models.tstests/e2e/orm/schemas/basic/schema.tstests/e2e/orm/schemas/name-mapping/models.tstests/e2e/orm/schemas/name-mapping/input.tstests/e2e/orm/schemas/typing/schema.tspackages/orm/src/client/crud/validator/index.tstests/e2e/orm/schemas/todo/schema.tstests/e2e/orm/schemas/name-mapping/schema.tstests/e2e/orm/schemas/petstore/models.tstests/e2e/orm/schemas/basic/models.tstests/e2e/orm/schemas/delegate/models.tstests/e2e/orm/schemas/typing/models.ts
📚 Learning: 2025-10-21T16:09:31.218Z
Learnt from: ymc9
Repo: zenstackhq/zenstack-v3 PR: 319
File: packages/runtime/src/client/executor/zenstack-query-executor.ts:63-72
Timestamp: 2025-10-21T16:09:31.218Z
Learning: In ZenStack, TypeDefs can be inherited by models. When a TypeDef contains fields with `map` attributes, those mapped field names need to be processed by the QueryNameMapper since they become part of the inheriting model's schema. Therefore, when checking if a schema has mapped names (e.g., in `schemaHasMappedNames`), both `schema.models` and `schema.typeDefs` must be inspected for `@map` and `map` attributes.
Applied to files:
tests/e2e/orm/schemas/delegate/schema.tstests/e2e/orm/schemas/petstore/schema.tstests/e2e/orm/schemas/basic/schema.tstests/e2e/orm/schemas/name-mapping/models.tstests/e2e/orm/schemas/typing/schema.tstests/e2e/orm/schemas/todo/schema.tstests/e2e/orm/schemas/name-mapping/schema.ts
📚 Learning: 2025-09-04T12:38:14.150Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-04T12:38:14.150Z
Learning: Applies to pnpm-workspace.yaml : Use pnpm workspaces for the monorepo
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-09-04T12:38:14.150Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-04T12:38:14.150Z
Learning: Applies to **/schema.zmodel : Name ZModel schema files `schema.zmodel`
Applied to files:
packages/orm/src/client/crud/validator/index.ts
📚 Learning: 2025-09-04T12:38:14.150Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-04T12:38:14.150Z
Learning: Applies to package.json : Pin the repository package manager to `pnpm10.12.1` via the `packageManager` field
Applied to files:
package.json
🧬 Code graph analysis (11)
tests/e2e/orm/schemas/delegate/schema.ts (1)
packages/orm/src/schema/expression.ts (1)
ExpressionUtils(16-120)
tests/e2e/orm/schemas/petstore/schema.ts (1)
packages/orm/src/schema/expression.ts (1)
ExpressionUtils(16-120)
tests/e2e/orm/schemas/todo/models.ts (5)
tests/e2e/orm/schemas/basic/models.ts (1)
User(10-10)tests/e2e/orm/schemas/delegate/models.ts (1)
User(10-10)tests/e2e/orm/schemas/name-mapping/models.ts (1)
User(10-10)tests/e2e/orm/schemas/petstore/models.ts (1)
User(10-10)tests/e2e/orm/schemas/typing/models.ts (1)
User(10-10)
tests/e2e/orm/schemas/basic/schema.ts (1)
packages/orm/src/schema/expression.ts (1)
ExpressionUtils(16-120)
tests/e2e/orm/schemas/name-mapping/models.ts (5)
tests/e2e/orm/schemas/basic/models.ts (2)
User(10-10)Post(11-11)tests/e2e/orm/schemas/delegate/models.ts (1)
User(10-10)tests/e2e/orm/schemas/petstore/models.ts (1)
User(10-10)tests/e2e/orm/schemas/todo/models.ts (1)
User(12-12)tests/e2e/orm/schemas/typing/models.ts (2)
User(10-10)Post(11-11)
packages/orm/src/client/crud/validator/utils.ts (1)
packages/orm/src/client/crud/validator/index.ts (1)
schema(59-61)
tests/e2e/orm/schemas/typing/schema.ts (1)
packages/orm/src/schema/expression.ts (1)
ExpressionUtils(16-120)
tests/e2e/orm/schemas/delegate/input.ts (1)
tests/e2e/orm/schemas/basic/input.ts (40)
UserFindManyArgs(11-11)UserFindUniqueArgs(12-12)UserFindFirstArgs(13-13)UserCreateArgs(14-14)UserCreateManyArgs(15-15)UserCreateManyAndReturnArgs(16-16)UserUpdateArgs(17-17)UserUpdateManyArgs(18-18)UserUpdateManyAndReturnArgs(19-19)UserUpsertArgs(20-20)UserDeleteArgs(21-21)UserDeleteManyArgs(22-22)UserCountArgs(23-23)UserAggregateArgs(24-24)UserGroupByArgs(25-25)UserWhereInput(26-26)UserSelect(27-27)UserInclude(28-28)UserOmit(29-29)UserGetPayload(30-30)CommentFindManyArgs(51-51)CommentFindUniqueArgs(52-52)CommentFindFirstArgs(53-53)CommentCreateArgs(54-54)CommentCreateManyArgs(55-55)CommentCreateManyAndReturnArgs(56-56)CommentUpdateArgs(57-57)CommentUpdateManyArgs(58-58)CommentUpdateManyAndReturnArgs(59-59)CommentUpsertArgs(60-60)CommentDeleteArgs(61-61)CommentDeleteManyArgs(62-62)CommentCountArgs(63-63)CommentAggregateArgs(64-64)CommentGroupByArgs(65-65)CommentWhereInput(66-66)CommentSelect(67-67)CommentInclude(68-68)CommentOmit(69-69)CommentGetPayload(70-70)
tests/e2e/orm/schemas/todo/schema.ts (1)
packages/orm/src/schema/expression.ts (1)
ExpressionUtils(16-120)
tests/e2e/orm/schemas/name-mapping/schema.ts (1)
packages/orm/src/schema/expression.ts (1)
ExpressionUtils(16-120)
tests/e2e/orm/schemas/typing/models.ts (5)
tests/e2e/orm/schemas/basic/models.ts (3)
User(10-10)Post(11-11)Profile(13-13)tests/e2e/orm/schemas/delegate/models.ts (1)
User(10-10)tests/e2e/orm/schemas/name-mapping/models.ts (2)
User(10-10)Post(11-11)tests/e2e/orm/schemas/petstore/models.ts (1)
User(10-10)tests/e2e/orm/schemas/todo/models.ts (1)
User(12-12)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Cleanup artifacts
- GitHub Check: build-test (20.x, sqlite)
- GitHub Check: build-test (20.x, postgresql)
- GitHub Check: claude-review
🔇 Additional comments (29)
packages/testtools/src/vitest-ext.ts (1)
22-32: No action needed — case-insensitive matching is justified for Zod v4 compatibility.Zod v4 changed the built-in error-message formatting including wording and casing as part of error-unification. The case-insensitive comparison on line 24 is a reasonable and pragmatic approach for the test utilities to handle these breaking changes between v3 and v4 error message formats. The implementation is correct and this is appropriate for test infrastructure code.
packages/orm/package.json (1)
100-100: LGTM! Zod v4 upgrade is correctly applied.The devDependency upgrade to
^4.1.0aligns with the PR objective and allows for future patch and minor updates within the v4 line.packages/zod/package.json (1)
34-34: LGTM! Zod v4 devDependency upgrade is consistent.The upgrade to
^4.1.0aligns with the workspace-wide migration to Zod v4.pnpm-workspace.yaml (1)
7-7: LGTM! Workspace constraint correctly enforces Zod v4.This change drops Zod v3 support and enforces
^4.0.0workspace-wide, aligning with the PR objective to require Zod 4 or above.tests/e2e/orm/schemas/delegate/models.ts (1)
8-16: Auto-generated formatting changes look correct.These quote formatting changes are consistent with the code generator's output. No semantic changes detected.
packages/server/package.json (1)
152-152: LGTM! Zod v4 devDependency upgrade is consistent.The upgrade to
^4.1.0aligns with the workspace-wide migration to Zod v4.tests/e2e/orm/schemas/typing/models.ts (1)
8-21: LGTM! Auto-generated changes include formatting and new Status export.The formatting changes and new
Statustype export are consistent with the code generator's output. The addition of the Status export aligns with the schema's enum definitions.tests/e2e/orm/schemas/name-mapping/schema.ts (1)
8-87: LGTM! Auto-generated formatting changes are consistent.All changes are quote style formatting (single to double quotes) with no semantic modifications to the schema structure. This is expected output from the code generator.
tests/e2e/orm/schemas/petstore/schema.ts (1)
1-157: LGTM! Formatting updates align with project standards.This auto-generated schema file has been reformatted with double-quoted string literals throughout, maintaining identical semantics and structure. The changes are purely cosmetic and consistent with the project-wide quote standardization effort.
tests/e2e/orm/schemas/basic/schema.ts (1)
1-285: LGTM! Consistent formatting updates.Auto-generated schema file reformatted with double-quoted string literals. No semantic changes to the schema structure, models, fields, or relationships.
tests/e2e/orm/schemas/name-mapping/models.ts (1)
8-11: LGTM! Import and type alias formatting updated.The import paths and generic type parameters have been reformatted to use double quotes. Public API surface (type names and signatures) remains unchanged.
tests/e2e/orm/schemas/typing/schema.ts (1)
1-343: LGTM! Formatting updates with consistent quote style.Auto-generated schema file updated with double-quoted string literals throughout. The import addition of
OperandExpressionand all structural elements remain semantically identical.tests/e2e/orm/schemas/delegate/schema.ts (1)
1-465: LGTM! Consistent formatting normalization.Auto-generated schema file with string literal quote standardization. All model definitions, fields, relations, and discriminator logic remain functionally identical.
tests/e2e/orm/schemas/petstore/input.ts (1)
8-70: LGTM! Import consolidation and formatting improvements.The imports have been consolidated into fewer lines, and all type aliases are reformatted with double-quoted string literals. Public API surface remains unchanged—all type names and generic parameters are identical.
tests/e2e/orm/schemas/basic/input.ts (1)
8-90: LGTM! Consolidated imports and consistent formatting.Imports consolidated and type aliases reformatted with double quotes. Public type definitions for User, Post, Comment, and Profile remain functionally identical.
packages/orm/src/client/crud/validator/utils.ts (2)
174-194: LGTM! Correct Zod v4 error issue transformation.The error handling has been properly updated for Zod v4:
- Changed from
error?.errorstoerror?.issues(Zod v4 standard)- Transforms numeric validation errors into proper Zod issue objects with
too_small/too_bigcodes- Includes all required metadata:
minimum/maximum,inclusive,type, and preserves original messagesThe issue structure aligns with Zod v4's unified error handling approach.
279-282: LGTM! Proper Zod v4 API update.The options type and field name have been correctly updated for Zod v4:
- Uses
Parameters<typeof schema.refine>[1]for type-safe options inference- Renames
messagetoerror, aligning with Zod v4's unified error customization APIThis matches the Zod v4 documentation's unified error parameter approach.
tests/e2e/orm/schemas/basic/models.ts (1)
1-16: Generated file - formatting changes look correct.This file is auto-generated by ZenStack CLI. The changes are purely formatting updates (single to double quotes) with no functional impact. No review needed.
tests/e2e/orm/schemas/delegate/input.ts (1)
1-150: Generated file - import consolidation and formatting changes are correct.This file is auto-generated by ZenStack CLI. The changes consolidate imports and update quote styles without affecting functionality.
packages/orm/src/client/crud/validator/index.ts (3)
5-5: Correct Zod v4 migration: ZodSchema removed from imports.The removal of
ZodSchemafrom imports aligns with Zod v4, whereZodTypeis the primary type. This change is consistent throughout the file.
1390-1390: Explicitanytype annotation is consistent with existing patterns.The addition of
(value: any)is consistent with other refinement callbacks in this file (e.g., lines 483, 1208, 1223, 1469, 1476). Whileanyreduces type safety, it's appropriate here since the refinement validates the structure at runtime.
1417-1417: Explicitanytype annotation is consistent with existing patterns.The addition of
(value: any)matches the pattern used elsewhere in the file for refinement callbacks.BREAKINGCHANGES.md (1)
5-5: Documentation update looks good.The addition of "SWR plugin is removed" to the breaking changes list is clear and consistent with the existing format.
tests/e2e/orm/schemas/name-mapping/input.ts (1)
1-50: Generated file - formatting changes are correct.This file is auto-generated by ZenStack CLI. The changes are formatting updates (import consolidation and quote style) with no functional impact.
tests/e2e/orm/schemas/todo/models.ts (1)
1-14: Generated file - quote style changes are correct.This file is auto-generated by ZenStack CLI. The changes are purely formatting (single to double quotes) with no functional impact.
tests/e2e/orm/schemas/todo/schema.ts (1)
1-396: Generated file - quote style changes are correct.This file is auto-generated by ZenStack CLI. The changes convert all single quotes to double quotes throughout the schema definition, with no functional impact.
tests/e2e/orm/schemas/petstore/models.ts (1)
1-12: Generated file - formatting changes are correct.This file is auto-generated by ZenStack CLI. The changes are formatting updates (quote style) with no functional impact.
tests/e2e/orm/schemas/typing/input.ts (1)
1-130: LGTM! Auto-generated formatting updates.The changes are purely cosmetic formatting updates from the ZenStack CLI code generator: consolidated imports, double-quoted strings, and single-line type aliases. No functional changes to the API surface.
tests/e2e/orm/schemas/todo/input.ts (1)
1-110: LGTM! Auto-generated formatting updates.The changes are purely cosmetic formatting updates from the ZenStack CLI code generator: consolidated imports, double-quoted strings, and single-line type aliases. No functional changes to the API surface.
|
I'll analyze this and get back to you. |
|
I'll analyze this and get back to you. |

Summary by CodeRabbit
Breaking Changes
Chores
Bug Fixes