Skip to content

chore: upgrade to zod v4 - #4039

Open
carderne wants to merge 14 commits into
mainfrom
chore/zod-4
Open

chore: upgrade to zod v4#4039
carderne wants to merge 14 commits into
mainfrom
chore/zod-4

Conversation

@carderne

@carderne carderne commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Zod v4 compatibility

Upgrades the monorepo's internal zod version from 3.x to 4.4.3 and widens the peer
dependency on all published packages to "^3.25.0 || ^4.0.0".

For library consumers

No breaking change if you are on zod 3.25+. The peer dependency range is widened, not
narrowed — your existing zod 3.25+ install continues to satisfy it and the library code
is runtime-compatible with both versions. Zod 4.x is now also supported. Bumped as minor
across all affected packages.

Minimum zod 3 version is 3.25.0 (not 3.0.0).

API compatibility

Zod types appear in the public API of @trigger.dev/core and @trigger.dev/redis-worker
(generic constraints like T extends z.ZodTypeAny, exported schema values typed as
z.ZodType<T>, and WorkerCatalog's schema field). These types exist in both zod 3 and
zod 4, so TypeScript consumers on either version should resolve them without errors —
the shapes are structurally compatible across versions.

If you pass your own zod schemas into library APIs (e.g. zodfetch, zodShapeStream,
WorkerCatalog), schemas from zod 3.25+ and zod 4.x are both accepted.

WorkerCatalog uses z.ZodFirstPartySchemaTypes, which is present in zod 4 via a
compatibility alias but marked @deprecated. This is intentional — the type is still
fully functional, and we've left it in place to avoid a breaking API change.

TODO list before merging

  • bump @trigger.dev/platform dep to 1.2.1 when that becomes available

@changeset-bot

changeset-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 88ac588

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

This PR includes changesets to release 27 packages
Name Type
@trigger.dev/core Minor
@trigger.dev/sdk Minor
trigger.dev Minor
@trigger.dev/redis-worker Minor
@trigger.dev/schema-to-json Minor
@trigger.dev/build Minor
@trigger.dev/python Minor
@internal/cache Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@internal/metrics-pipeline Patch
@trigger.dev/rbac Minor
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/run-store Patch
@internal/schedule-engine Patch
@trigger.dev/sso Minor
@internal/testcontainers Patch
@internal/tracing Patch
@internal/tsql Patch
@internal/dashboard-agent Patch
@internal/sdk-compat-tests Patch
@trigger.dev/react-hooks Minor
@trigger.dev/rsc Minor
@trigger.dev/database Minor
@trigger.dev/otlp-importer Minor

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

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Package manifests and overrides update Zod versions, peer ranges, and dependency placement across the workspace. Core and webapp schemas switch to explicit string-keyed records and adjust a few field shapes. Webapp routes and components migrate to parseWithZod, getFormProps, and .errors-based rendering. Several helpers and runtime paths add casts or updated type aliases to match Zod v4 APIs.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the Zod v4 migration but omits the required issue reference, checklist, testing, changelog, and screenshots sections. Add the required template sections, including an issue reference, completed checklist, testing steps, changelog summary, and screenshots or a stated reason they are not applicable.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the primary change: upgrading the project to Zod v4.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/zod-4

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.

@pkg-pr-new

pkg-pr-new Bot commented Jun 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@88ac588

trigger.dev

npm i https://pkg.pr.new/trigger.dev@88ac588

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@88ac588

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@88ac588

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@88ac588

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@88ac588

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@88ac588

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@88ac588

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@88ac588

commit: 88ac588

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{"name":"HttpError","status":500,"request":{"method":"PATCH","url":"https://api.github.com/repos/triggerdotdev/trigger.dev/issues/comments/4799766654","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.6 Node.js/24","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- review_stack_entry_start -->\n\n[![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/triggerdotdev/trigger.dev/pull/4039?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)\n\n<!-- review_stack_entry_end -->\n<!-- This is an auto-generated comment: review in progress by coderabbit.ai -->\n\n> [!NOTE]\n> Currently processing new changes in this PR. This may take a few minutes, please wait...\n> \n> <details>\n> <summary>⚙️ Run configuration</summary>\n> \n> **Configuration used**: Repository UI\n> \n> **Review profile**: CHILL\n> \n> **Plan**: Pro\n> \n> **Run ID**: `8fad56a2-0f47-4f9f-b9bc-59ba132bf08d`\n> \n> </details>\n> \n> <details>\n> <summary>📥 Commits</summary>\n> \n> Reviewing files that changed from the base of the PR and between d565949205ab1fefbc2cbf8bf5ab826207f3192e and 3d5ccd22d7736c6a1545298e1da9626a721e55ac.\n> \n> </details>\n> \n> <details>\n> <summary>⛔ Files ignored due to path filters (1)</summary>\n> \n> * `pnpm-lock.yaml` is excluded by `!**/pnpm-lock.yaml`\n> \n> </details>\n> \n> <details>\n> <summary>📒 Files selected for processing (82)</summary>\n> \n> * `.changeset/zod-4-support.md`\n> * `apps/supervisor/package.json`\n> * `apps/webapp/app/components/metrics/QueryWidget.tsx`\n> * `apps/webapp/app/models/orgIntegration.server.ts`\n> * `apps/webapp/app/models/vercelIntegration.server.ts`\n> * `apps/webapp/app/models/vercelSdkRecovery.server.ts`\n> * `apps/webapp/app/presenters/v3/MetricDashboardPresenter.server.ts`\n> * `apps/webapp/app/presenters/v3/SpanPresenter.server.ts`\n> * `apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.environment-variables.new/route.tsx`\n> * `apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx`\n> * `apps/webapp/app/routes/_app.orgs.$organizationSlug.settings.billing-alerts/route.tsx`\n> * `apps/webapp/app/routes/account._index/route.tsx`\n> * `apps/webapp/app/routes/account.tokens/route.tsx`\n> * `apps/webapp/app/routes/admin.feature-flags.tsx`\n> * `apps/webapp/app/routes/api.v1.plain.customer-cards.ts`\n> * `apps/webapp/app/routes/api.v1.prompts.$slug.ts`\n> * `apps/webapp/app/routes/api.v1.query.ts`\n> * `apps/webapp/app/routes/api.v1.schedules.ts`\n> * `apps/webapp/app/routes/resources.feedback.ts`\n> * `apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.schedules.new/route.tsx`\n> * `apps/webapp/app/services/apiAuth.server.ts`\n> * `apps/webapp/app/services/authorizationRateLimitMiddleware.server.ts`\n> * `apps/webapp/app/services/queryService.server.ts`\n> * `apps/webapp/app/services/routeBuilders/apiBuilder.server.ts`\n> * `apps/webapp/app/services/routeBuilders/dashboardBuilder.server.ts`\n> * `apps/webapp/app/services/routeBuilders/dashboardBuilder.ts`\n> * `apps/webapp/app/utils/json.ts`\n> * `apps/webapp/app/utils/timeGranularity.ts`\n> * `apps/webapp/app/v3/featureFlags.server.ts`\n> * `apps/webapp/app/v3/featureFlags.ts`\n> * `apps/webapp/app/v3/marqs/types.ts`\n> * `apps/webapp/app/v3/schedules.ts`\n> * `apps/webapp/app/v3/services/aiRunFilterService.server.ts`\n> * `apps/webapp/app/v3/services/replayTaskRun.server.ts`\n> * `apps/webapp/app/v3/utils/zodPubSub.server.ts`\n> * `apps/webapp/app/v3/vercel/vercelProjectIntegrationSchema.ts`\n> * `apps/webapp/package.json`\n> * `internal-packages/clickhouse/package.json`\n> * `internal-packages/clickhouse/src/client/tsql.ts`\n> * `internal-packages/clickhouse/src/tsqlFunctions.test.ts`\n> * `internal-packages/compute/package.json`\n> * `internal-packages/compute/src/types.ts`\n> * `internal-packages/emails/package.json`\n> * `internal-packages/run-engine/package.json`\n> * `internal-packages/run-engine/src/batch-queue/types.ts`\n> * `internal-packages/schedule-engine/package.json`\n> * `internal-packages/tsql/package.json`\n> * `internal-packages/zod-worker/package.json`\n> * `internal-packages/zod-worker/src/index.ts`\n> * `package.json`\n> * `packages/cli-v3/package.json`\n> * `packages/cli-v3/src/cli/common.ts`\n> * `packages/cli-v3/src/commands/analyze.ts`\n> * `packages/cli-v3/src/mcp/tools/agentChat.ts`\n> * `packages/cli-v3/src/utilities/configFiles.ts`\n> * `packages/core/package.json`\n> * `packages/core/src/schemas/eventFilter.ts`\n> * `packages/core/src/schemas/json.ts`\n> * `packages/core/src/v3/apiClient/index.ts`\n> * `packages/core/src/v3/runEngineWorker/supervisor/schemas.ts`\n> * `packages/core/src/v3/schemas/api.ts`\n> * `packages/core/src/v3/schemas/build.ts`\n> * `packages/core/src/v3/schemas/common.ts`\n> * `packages/core/src/v3/schemas/eventFilter.ts`\n> * `packages/core/src/v3/schemas/messages.ts`\n> * `packages/core/src/v3/schemas/openTelemetry.ts`\n> * `packages/core/src/v3/schemas/query.ts`\n> * `packages/core/src/v3/schemas/resources.ts`\n> * `packages/core/src/v3/schemas/runEngine.ts`\n> * `packages/core/src/v3/schemas/schemas.ts`\n> * `packages/core/src/v3/serverOnly/httpServer.ts`\n> * `packages/core/src/v3/types/tools.ts`\n> * `packages/core/src/v3/zodIpc.ts`\n> * `packages/core/src/v3/zodMessageHandler.ts`\n> * `packages/core/src/v3/zodNamespace.ts`\n> * `packages/core/src/v3/zodSocket.ts`\n> * `packages/redis-worker/package.json`\n> * `packages/redis-worker/src/mollifier/schemas.ts`\n> * `packages/redis-worker/src/queue.ts`\n> * `packages/redis-worker/src/worker.ts`\n> * `packages/schema-to-json/package.json`\n> * `packages/trigger-sdk/package.json`\n> \n> </details>\n> \n> \n\n<!-- end of auto-generated comment: review in progress by coderabbit.ai -->\n\n<!-- finishing_touch_checkbox_start -->\n\n<details>\n<summary>✨ Finishing Touches</summary>\n\n<details>\n<summary>📝 Generate docstrings</summary>\n\n- [ ] <!-- {\"checkboxId\": \"7962f53c-55bc-4827-bfbf-6a18da830691\"} --> Create stacked PR\n- [ ] <!-- {\"checkboxId\": \"3e1879ae-f29b-4d0d-8e06-d12b7ba33d98\"} --> Commit on current branch\n\n</details>\n<details>\n<summary>🧪 Generate unit tests (beta)</summary>\n\n- [ ] <!-- {\"checkboxId\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Create PR with unit tests\n- [ ] <!-- {\"checkboxId\": \"6ba7b810-9dad-11d1-80b4-00c04fd430c8\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Commit unit tests in branch `chore/zod-4`\n\n</details>\n\n</details>\n\n<!-- finishing_touch_checkbox_end -->\n<!-- tips_start -->\n\n---\n\nThanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=triggerdotdev/trigger.dev&utm_content=4039)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.\n\n<details>\n<summary>❤️ Share</summary>\n\n- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)\n- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)\n- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)\n- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)\n\n</details>\n\n\n<sub>Comment `@coderabbitai help` to get the list of available commands.</sub>\n\n<!-- tips_end -->"},"request":{"retryCount":3,"signal":{},"retries":3,"retryAfter":16}}}

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@carderne
carderne marked this pull request as ready for review June 25, 2026 18:37
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@carderne
carderne marked this pull request as draft June 29, 2026 14:35
@carderne
carderne force-pushed the chore/zod-4 branch 3 times, most recently from c60f28b to d42abf1 Compare July 3, 2026 15:00
@carderne
carderne marked this pull request as ready for review July 3, 2026 15:28
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@carderne
carderne marked this pull request as draft July 3, 2026 16:20
@carderne
carderne marked this pull request as ready for review August 3, 2026 16:09
devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration 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.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment on lines +667 to +669
"peerDependencies": {
"zod": "^3.25.0 || ^4.0.0"
}

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.

🔴 Installing the React hooks or build packages no longer pulls in a required validation library

The validation library is no longer installed automatically for anyone who installs the shared core library ("zod" moved to peerDependencies at packages/core/package.json:667-669), yet three published packages that load core's runtime code still declare no dependency on it, so installing them on their own leaves the library missing and they crash on import.
Impact: Users who add @trigger.dev/react-hooks, @trigger.dev/build, or @trigger.dev/rsc without also installing the SDK/CLI get a module-not-found failure at startup.

Why the peer-dependency move leaves sibling packages without zod

Before this PR, zod was a regular dependency of @trigger.dev/core, so any package depending on core got zod installed transitively. It is now devDependencies + peerDependencies only.

@trigger.dev/core still imports zod at runtime in its shipped entrypoints (e.g. packages/core/src/v3/apiClient/index.ts:1906 uses z.record(...)).

Published packages that depend on core but declare neither a zod dependency nor a zod peer:

  • packages/react-hooks/package.json — value import import { ApiClient } from "@trigger.dev/core/v3" (packages/react-hooks/src/hooks/useApiClient.ts:4); this is the most likely standalone install (frontend apps that don't install the SDK).
  • packages/build/package.json — value import import { BuildManifest } from "@trigger.dev/core/v3" (packages/build/src/internal/additionalFiles.ts:1).
  • packages/rsc/package.json.

@trigger.dev/sdk, trigger.dev (CLI) and @trigger.dev/redis-worker are fine — they declare zod as a peer or direct dependency.

Under pnpm (and any strict node_modules layout) the unmet peer is not hoisted, so require("zod") from inside core fails at import time.

Prompt for agents
Moving `zod` out of `@trigger.dev/core`'s `dependencies` into `peerDependencies` means packages that depend on core no longer get zod installed transitively. `@trigger.dev/react-hooks`, `@trigger.dev/build` and `@trigger.dev/rsc` are published packages that import core's runtime code (which imports zod) but declare no zod dependency or peer dependency of their own, so a standalone install of any of them will fail to resolve zod under strict node_modules layouts. Decide on a consistent policy: either add the same `"zod": "^3.25.0 || ^4.0.0"` peer dependency (plus a dev dependency pinned to 4.4.3) to those packages and include them in the changeset, or keep zod as a regular dependency of core.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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