fix(core): Widen zod peer dependency range in published packages (no-changelog)#29376
Merged
fix(core): Widen zod peer dependency range in published packages (no-changelog)#29376
Conversation
…changelog) Replace the exact `catalog:` (3.25.67) zod peer pin in `n8n-workflow`, `n8n-core`, and `@n8n/api-types` with a real semver range (`>=3.25.0 <4`). The exact pin was correct for our internal usage but is not what package managers act on when resolving a peer dependency: an exact version is treated as a single point, so consumers whose other dependencies pull in an older zod (e.g. 3.24.x) silently satisfy the peer with a warning instead of an actionable error. Source code in `n8n-workflow` imports `zod/v4`, a subpath that was only added in zod 3.25.0, so installs that land on an older zod fail at runtime with a cryptic `Package subpath './v4' is not defined by "exports"` deep inside `require-in-the-middle`. Widening the peer range to `>=3.25.0 <4` makes the install-time signal meaningful for downstream consumers (and lets `pnpm install --strict-peer-dependencies` fail rather than warn). Made-with: Cursor
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
No issues found across 3 files
Architecture diagram
sequenceDiagram
participant Dev as Consumer (Dev/CI)
participant PM as Package Manager (pnpm/npm)
participant App as Node.js Process
participant Core as n8n Packages (workflow/core)
participant Zod as zod (Dependency)
Note over PM, Core: Dependency Resolution Phase
Dev->>PM: Run installation (pnpm install)
PM->>Core: Read package.json peerDependencies
alt zod version < 3.25.0
PM-->>Dev: CHANGED: Emit actionable warning or hard failure (strict-peer-dependencies)
Note right of PM: Previously exact-version pin caused cryptic silent failures
else zod version >= 3.25.0 < 4.0.0
PM-->>Dev: Resolution successful
end
Note over App, Zod: Runtime Execution Phase
Dev->>App: Execute application (e.g. n8n start)
App->>Core: Load module
Core->>Zod: CHANGED: Resolve 'zod/v4' subpath
alt Resolved zod < 3.25.0
Zod-->>Core: THROW: "Package subpath './v4' is not defined"
Core-->>App: Runtime Crash (Sentry Alert)
else Resolved zod >= 3.25.0
Note over Zod: Subpath './v4' available in exports
Zod-->>Core: Module loaded successfully
Core-->>App: Execution continues
end
Note over Dev, Zod: Downstream remediation via overrides/resolutions ensures valid range matches runtime contract
Contributor
Performance ComparisonComparing current → latest master → 14-day baseline Memory consumption baseline with starter plan resources
Idle baseline with Instance AI module loaded
docker-stats
How to read this table
|
Bundle ReportBundle size has no change ✅ |
lucamattiazzi
approved these changes
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the exact
catalog:(zod@3.25.67) peer-dependency pin in the published packagesn8n-workflow,n8n-core, and@n8n/api-typeswith a real semver range:">=3.25.0 <4".Why
PR #28604 correctly moved
zodtopeerDependenciesin these three packages to enforce a single zod instance across the workspace. The peer was declared as"catalog:", which gets published as the exact catalog version (3.25.67).That exact pin is what we want for our own builds, but it is not how package managers act on a peer:
3.24.xvia another transitive) silently satisfy the peer and only emit a warning.import … from 'zod/v4'(the subpath was added in zod 3.25.0), so installs that resolve to an older zod fail at runtime with a crypticPackage subpath './v4' is not defined by "exports"deep insiderequire-in-the-middle. We've been seeing this in production via Sentry alerts oncreators-nodes-sync.Widening the peer to
">=3.25.0 <4":pnpm install --strict-peer-dependenciesfail on a too-old zod instead of just warning.Downstream remediation
Consumers seeing the cryptic error today (e.g.
creators-nodes-sync) should pin zod viapackage.json:…or the equivalent
overrides(npm) /resolutions(yarn) idiom, then reinstall.What this PR is not
An earlier draft of this PR also added a load-time runtime guard inside
n8n-workflowto throw a clearer error if the consumer's resolved zod was too old. Self-review uncovered that the guard:n8n-workflowCJS build (resolveJsonModule: falseis set in@n8n/typescript-config/modern/tsconfig.cjs.json, soimport 'zod/package.json'did not compile), andwith { type: 'json' }import attributes.It was reverted. The peer-range change alone is the smaller, safer win. We can revisit a runtime guard later (likely via
createRequire+ filesystem read, with a built-artifact integration test) if needed.Related Linear tickets, Github issues, and Community forum posts
Sentry alert:
creators-nodes-sync— issue7440848191(Module.patchedRequire(require-in-the-middle:index)—Package subpath './v4' is not defined by "exports"inn8n-workflow@2.18.3_zod@3.24.2).Follows up on #28604.
Review / Merge checklist
pnpm test,pnpm lint,pnpm typecheck, andpnpm buildinpackages/workfloware all clean.pnpm installproduces no lockfile diff.)Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)Made with Cursor