From 0eea6f2047cab2ce9807ee6b61bf98b78434e155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ullrich=20Sch=C3=A4fer?= Date: Sun, 19 Apr 2026 11:35:39 +0200 Subject: [PATCH] Upgrade zod from 3 to 4 Mechanical bump across the three packages that pull zod directly: - packages/api (8 schema files, ~300 lines) - apps/journal (persona schema in demo-bot.server.ts, 5 API route handlers that introspect parsed.error.issues) - apps/mobile (declared dep; no active imports yet) No code changes required. The legacy methods we use (.url(), .uuid(), .datetime() on strings) still parse identically in v4 via the compat shim, and z.ZodIssueCode.custom retains its runtime value. Error-issue introspection (parsed.error.issues.map(i => ...)) keeps the same shape at the fields we read (path, message, code). All 147 tests across journal + api + packages pass against zod 4.3.6. Follow-ups out of scope for this PR: - Modernise to top-level validator helpers (z.url(), z.iso.datetime()). The legacy string methods are deprecated but not removed. - Consider migrating error introspection to the richer v4 shape (.path is now branded, .input is new) if we ever want structured error surfaces. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/journal/package.json | 2 +- apps/mobile/package.json | 2 +- packages/api/package.json | 2 +- pnpm-lock.yaml | 17 +++++++++++------ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/apps/journal/package.json b/apps/journal/package.json index 62c0ca7..b036f5b 100644 --- a/apps/journal/package.json +++ b/apps/journal/package.json @@ -36,7 +36,7 @@ "react": "catalog:", "react-dom": "catalog:", "react-router": "catalog:", - "zod": "^3.25.0" + "zod": "^4.0.0" }, "devDependencies": { "@react-router/dev": "catalog:", diff --git a/apps/mobile/package.json b/apps/mobile/package.json index a3b13dc..4bd2597 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -66,7 +66,7 @@ "react-native-safe-area-context": "~5.6.2", "react-native-screens": "~4.23.0", "use-latest-callback": "^0.3.3", - "zod": "^3.25.76" + "zod": "^4.0.0" }, "devDependencies": { "@testing-library/react-native": "^13.3.3", diff --git a/packages/api/package.json b/packages/api/package.json index 2e8b628..1c5432e 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -10,6 +10,6 @@ "typecheck": "tsc" }, "dependencies": { - "zod": "^3.25.0" + "zod": "^4.0.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c61e98a..3cd855d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -267,8 +267,8 @@ importers: specifier: 'catalog:' version: 7.14.1(react-dom@19.2.5(react@19.2.5))(react@19.2.5) zod: - specifier: ^3.25.0 - version: 3.25.76 + specifier: ^4.0.0 + version: 4.3.6 devDependencies: '@react-router/dev': specifier: 'catalog:' @@ -418,8 +418,8 @@ importers: specifier: ^0.3.3 version: 0.3.3(react@19.2.5) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.0 + version: 4.3.6 devDependencies: '@testing-library/react-native': specifier: ^13.3.3 @@ -576,8 +576,8 @@ importers: packages/api: dependencies: zod: - specifier: ^3.25.0 - version: 3.25.76 + specifier: ^4.0.0 + version: 4.3.6 packages/db: dependencies: @@ -7671,6 +7671,9 @@ packages: zod@3.25.76: resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==} + zod@4.3.6: + resolution: {integrity: sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==} + snapshots: '@adobe/css-tools@4.4.4': {} @@ -15661,3 +15664,5 @@ snapshots: yocto-queue@0.1.0: {} zod@3.25.76: {} + + zod@4.3.6: {}