Skip to content

chore(deps): update zod, remove use of deprecated APIs - #2864

Merged
ascorbic merged 7 commits into
emdash-cms:mainfrom
camc314:c/update-zod
Sep 8, 2026
Merged

ascorbic merged 7 commits into
emdash-cms:mainfrom
camc314:c/update-zod

Conversation

@camc314

@camc314 camc314 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

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

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool:

Screenshots / test output

Copilot AI lite review requested due to automatic review settings September 2, 2026 14:48
@changeset-bot

changeset-bot Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4380144

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
emdash Patch
@emdash-cms/auth Patch
@emdash-cms/plugin-cli Patch
@emdash-cms/plugin-types Patch
@emdash-cms/plugin-embeds Patch
@emdash-cms/plugin-forms Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/release-service Patch
@emdash-cms/admin Patch
@emdash-cms/registry-verification Patch
@emdash-cms/labeler Patch
@emdash-cms/release-action Patch
@emdash-cms/release-verifier Patch
@emdash-cms/blocks Patch
create-emdash Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch

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

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Scope check

This PR changes 1,203 lines across 42 files. Large PRs are harder to review and more likely to be closed without review.
This PR spans 4 different areas (area/core, area/plugins, area/docs, area/auth). Consider breaking it into smaller, focused PRs.

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.

@github-actions github-actions Bot added the review/needs-review No maintainer or bot review yet label Sep 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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(...), $ZodIssue typing).
  • 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),

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:125

    The 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
    

@github-actions github-actions Bot added cla: signed review/needs-rereview New commits since the last review overlap and removed review/needs-review No maintainer or bot review yet labels Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@pkg-pr-new

pkg-pr-new Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@2864

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@2864

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@2864

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@2864

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@2864

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@2864

emdash

npm i https://pkg.pr.new/emdash@2864

create-emdash

npm i https://pkg.pr.new/create-emdash@2864

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@2864

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@2864

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@2864

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@2864

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@2864

@emdash-cms/registry-moderation

npm i https://pkg.pr.new/@emdash-cms/registry-moderation@2864

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@2864

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@2864

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@2864

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@2864

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@2864

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@2864

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@2864

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@2864

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@2864

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@2864

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@2864

commit: 4380144

@ascorbic ascorbic added the bot:review Trigger an emdashbot code review on this PR label Sep 7, 2026
@emdashbot emdashbot Bot removed the bot:review Trigger an emdashbot code review on this PR label Sep 7, 2026
@ascorbic ascorbic added the bot:review Trigger an emdashbot code review on this PR label Sep 7, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@emdashbot emdashbot Bot removed the bot:review Trigger an emdashbot code review on this PR label Sep 7, 2026
@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-rereview New commits since the last review labels Sep 7, 2026

@khoinguyenpham04 khoinguyenpham04 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR! there's just some few nits

Comment thread pnpm-workspace.yaml Resolved
@github-actions github-actions Bot added review/needs-rereview New commits since the last review needs-rebase and removed review/approved Approved; no new commits since labels Sep 8, 2026
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 khoinguyenpham04 added the bot:review Trigger an emdashbot code review on this PR label Sep 8, 2026

@khoinguyenpham04 khoinguyenpham04 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

muchas gracias!

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:2279

    The workspace lockfile still resolves packages/marketplace to [email protected], while the rest of the catalog now uses [email protected]. Marketplace is part of packages/* 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-deprecated z.string().url() pattern. Consider updating packages/marketplace/package.json to use zod: catalog: and replacing z.string().url() with z.url() in src/routes/themes.ts and src/routes/author.ts so the whole workspace stays on one Zod version and one deprecation-free API set.

@emdashbot emdashbot Bot removed the bot:review Trigger an emdashbot code review on this PR label Sep 8, 2026
@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-rereview New commits since the last review labels Sep 8, 2026
@ascorbic
ascorbic merged commit ecdba4d into emdash-cms:main Sep 8, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants