Repository navigation
chore(deps): update zod, remove use of deprecated APIs - #2864
Conversation
🦋 Changeset detectedLatest commit: 4380144 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Scope checkThis PR changes 1,203 lines across 42 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
There was a problem hiding this comment.
🟡 Changes recommended
Plugin-route validation errors should include a stable error.details.issues array (in addition to formatted output) to keep error consumption consistent across the codebase.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates the monorepo’s Zod dependency to 4.5.4 and migrates internal and plugin schemas away from deprecated Zod v4 APIs/shorthands, keeping schema types consistent across package boundaries.
Changes:
- Bumps Zod to 4.5.4 in the pnpm catalog + lockfile and updates downstream dependency resolutions.
- Migrates schema code to Zod v4.5 idioms (e.g.,
z.email(),z.url(),z.iso.datetime(),.loose(),z.formatError(...),$ZodIssuetyping). - Adds a changeset documenting the patch-level dependency/schema update across published packages.
File summaries
| File | Description |
|---|---|
| pnpm-workspace.yaml | Pins workspace Zod catalog version to 4.5.4. |
| pnpm-lock.yaml | Updates lockfile resolutions for Zod bump and related transitive changes. |
| packages/plugins/forms/src/schemas.ts | Updates plugin-form schemas to Zod v4.5 APIs (z.url, z.email, z.iso.datetime). |
| packages/plugins/embeds/src/schemas.ts | Updates embed plugin URL schema to z.url() shorthand. |
| packages/plugin-types/src/manifest-schema.ts | Replaces .passthrough() with .loose() in manifest schema. |
| packages/plugin-cli/src/manifest/schema.ts | Migrates manifest schema validators to v4.5 shorthands and new composition (check). |
| packages/plugin-cli/src/manifest/load.ts | Updates Zod issue typing to $ZodIssue from v4 core path. |
| packages/core/tests/unit/plugins/routes.test.ts | Updates test schema to use z.email() shorthand. |
| packages/core/src/schema/zod-generator.ts | Updates generator to use ZodType and v4.5 shorthand schemas (z.url, .loose). |
| packages/core/src/plugins/routes.ts | Switches validation error formatting to z.formatError(...). |
| packages/core/src/plugins/manifest-schema.ts | Replaces .passthrough() with .loose() in core manifest schema. |
| packages/core/src/mcp/server.ts | Migrates schema definitions to .loose() and z.url() shorthand. |
| packages/core/src/fields/types.ts | Updates field schema typing from ZodTypeAny to ZodType. |
| packages/core/src/fields/textarea.ts | Updates field schema typing to ZodType. |
| packages/core/src/fields/text.ts | Updates field schema typing to ZodType. |
| packages/core/src/fields/slug.ts | Updates field schema typing to ZodType. |
| packages/core/src/fields/select.ts | Updates field schema typing to ZodType. |
| packages/core/src/fields/richtext.ts | Updates field schema typing to ZodType. |
| packages/core/src/fields/portable-text.ts | Replaces .passthrough() with .loose() for portable text blocks. |
| packages/core/src/fields/number.ts | Updates field schema typing to ZodType. |
| packages/core/src/fields/multiselect.ts | Updates field schema typing to ZodType. |
| packages/core/src/fields/json.ts | Updates field schema typing to ZodType. |
| packages/core/src/fields/integer.ts | Updates field schema typing to ZodType. |
| packages/core/src/fields/file.ts | Updates field schema typing to ZodType. |
| packages/core/src/fields/datetime.ts | Updates field schema typing to ZodType. |
| packages/core/src/fields/boolean.ts | Updates field schema typing to ZodType. |
| packages/core/src/astro/routes/api/settings/email.ts | Updates email validation to z.email(). |
| packages/core/src/astro/routes/api/admin/oauth-clients/index.ts | Migrates redirect URI validation to z.url() shorthand. |
| packages/core/src/astro/routes/api/admin/oauth-clients/[id].ts | Migrates redirect URI validation to z.url() shorthand. |
| packages/core/src/astro/routes/api/admin/api-tokens/index.ts | Migrates datetime validation to z.iso.datetime(). |
| packages/core/src/api/schemas/users.ts | Updates email validation to z.email(). |
| packages/core/src/api/schemas/setup.ts | Updates email validation to z.email(). |
| packages/core/src/api/schemas/redirects.ts | Migrates datetime validation to z.iso.datetime(). |
| packages/core/src/api/schemas/content.ts | Updates numeric comparable schema and OpenAPI-ish metadata examples field. |
| packages/core/src/api/schemas/common.ts | Migrates URL schema and meta example->examples in error schema. |
| packages/core/src/api/schemas/comments.ts | Updates email validation to z.email(). |
| packages/core/src/api/schemas/auth.ts | Updates email validation to z.email(). |
| packages/core/src/api/parse.ts | Updates issue typing to z.core.$ZodIssue. |
| packages/core/src/api/openapi/document.ts | Updates metadata from example to examples for collection path param. |
| packages/auth/src/config.ts | Updates OAuth config URL schema to z.url() shorthand. |
| docs/package.json | Bumps docs’ Zod dependency range to ^4.5.4. |
| .changeset/bright-zebras-validate.md | Adds changeset for the Zod upgrade across affected packages. |
Review details
- Files reviewed: 41/42 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| code: "VALIDATION_ERROR", | ||
| message: "Invalid request body", | ||
| details: parseResult.error.format(), | ||
| details: z.formatError(parseResult.error), |
There was a problem hiding this comment.
This is the right kind of maintenance PR: it bumps Zod to 4.5.4 and consistently replaces deprecated/removed APIs across EmDash's own packages and the native plugins. The lockfile confirms Astro 6.1.3 already resolves to [email protected], so the astro/zod re-export used by the field and plugin schemas stays in sync with the workspace catalog. I scanned for remaining deprecated calls (z.string().url(), z.string().email(), z.string().datetime(), .passthrough(), ZodTypeAny, ZodIssue) and didn't find any in source code.
Everything looks mechanically correct, with one exception: a stale comment in the Portable Text schema still refers to the old .passthrough() API even though the code now uses .loose(). That's a false technical claim that will mislead future readers and violates the comment-discipline rule in AGENTS.md.
Fix that comment and this should be good to merge.
Findings
-
[needs fixing]
packages/core/src/schema/zod-generator.ts:125The code was updated from
.passthrough()to.loose(), but this comment still describes the old API. A future reader relying on the comment will look for a method that no longer exists.// uses `.loose()` for everything below the top level. Making
Overlapping PRsThis PR modifies files that are also changed by other open PRs:
This may cause merge conflicts or duplicated work. A maintainer will coordinate. |
47443b5 to
80e6bce
Compare
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-moderation
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
d4e6f3d to
a5fad8f
Compare
There was a problem hiding this comment.
This is the right kind of maintenance change: it upgrades the workspace to Zod 4.5.4, pins the version in the pnpm catalog, and replaces deprecated/removed Zod APIs consistently across EmDash core, auth, plugin-cli, plugin-types, and the native plugins. The lockfile keeps Astro's astro/zod re-export on the same version as the runtime schemas, which matters because schemas cross package boundaries.
The previous review flagged one stale comment in packages/core/src/schema/zod-generator.ts that still referred to .passthrough() after the code moved to .loose(). That comment has been updated to match the code, so the only outstanding finding is resolved.
I rescanned the PR for remaining deprecated calls (z.string().url(), z.string().email(), z.string().datetime(), .passthrough(), ZodTypeAny, ZodIssue, the old .format() error formatter) and didn't find any in source code. Existing plugin-cli manifest-schema tests still accept https:// URLs and reject http:// and non-URL strings, confirming the new z.string().check(z.regex(...), z.url(...)) pattern behaves correctly, and the manifest-load tests cover Zod validation-error formatting. The changeset is concise and names the user-facing effect (schema compatibility across packages).
Approved.
khoinguyenpham04
left a comment
There was a problem hiding this comment.
thanks for the PR! there's just some few nits
Preserve the required MCP publication revision token alongside the Zod datetime compatibility schema. Extend the publish integration test to cover minute-precision timestamps with Z and timezone offsets.
khoinguyenpham04
left a comment
There was a problem hiding this comment.
muchas gracias!
There was a problem hiding this comment.
This is the right kind of maintenance change: it upgrades the EmDash workspace to Zod 4.5.4, replaces the Zod 4-deprecated string methods (z.string().url(), z.string().email(), z.string().datetime()) with their top-level/iso equivalents, swaps ZodTypeAny for ZodType, ZodIssue for z.core.$ZodIssue/$ZodIssue, and renames .passthrough() to .loose(). The lockfile dedupes Astro’s bundled astro/zod onto the same instance as the runtime schemas, which matters because schemas cross package boundaries.
The prior review’s only finding — a stale comment in packages/core/src/schema/zod-generator.ts that still said .passthrough() after the code moved to .loose() — has been fixed, so that issue is resolved.
I rescanned the tree for remaining deprecated/removed usages (z.string().url(), .email(), .datetime(), .passthrough(), ZodTypeAny, ZodIssue, the old parseResult.error.format() formatter, and the long-removed z.string().url()/z.string().email() inheritance). I didn’t find any in the touched packages. The new tests cover the intended behavior: minute-precision ISO datetimes pass the API and generator schemas, and the generator URL-field test confirms that maxLength/pattern constraints are still applied after the move to z.string().check(z.url()).
I also inspected the bundled Zod 4.5.4 code in apps/release-action/dist/index.js to confirm the z.number() parser rejects non-finite values, so dropping z.number().finite() for contentFieldComparable is behavior-preserving.
One non-blocking heads-up: packages/marketplace/package.json still depends on zod: ^3.25.67 and its route files still use the Zod 4-deprecated z.string().url() pattern (e.g. packages/marketplace/src/routes/themes.ts and src/routes/author.ts). The lockfile therefore resolves a second Zod major for the workspace. Marketplace is private and self-contained, so it does not break anything, but if the goal is one consistent Zod version across the whole workspace it should be moved to the catalog (zod: catalog:) and those calls should become z.url().
Approved.
Findings
-
[suggestion]
pnpm-lock.yaml:2279The workspace lockfile still resolves
packages/marketplaceto[email protected], while the rest of the catalog now uses[email protected]. Marketplace is part ofpackages/*and is not coupled to any shared schema package, so it is safe, but it leaves the workspace on two Zod majors and its routes still use the Zod 4-deprecatedz.string().url()pattern. Consider updatingpackages/marketplace/package.jsonto usezod: catalog:and replacingz.string().url()withz.url()insrc/routes/themes.tsandsrc/routes/author.tsso the whole workspace stays on one Zod version and one deprecation-free API set.
What does this PR do?
This PR updates zod to v4.5 which claims to have significant memory and performance improvements (release notes are here)
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.AI-generated code disclosure
Screenshots / test output