Skip to content

Commit df95d9b

Browse files
committed
chore: upgrade to zod v4
1 parent e5d7cff commit df95d9b

83 files changed

Lines changed: 386 additions & 345 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/zod-4-support.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@trigger.dev/core": patch
3+
"@trigger.dev/sdk": patch
4+
"trigger.dev": patch
5+
"@trigger.dev/redis-worker": patch
6+
"@trigger.dev/schema-to-json": patch
7+
---
8+
9+
Add zod v4 compatibility. The `zod` peer dependency is widened to `^3.25.0 || ^4.0.0`, so projects can use zod 3.25+ or zod 4. Internal code was updated for zod v4 API changes (`ZodError.errors``.issues`, single-arg `z.record` → keyed, unified `error` option, `z.ZodSchema`/`z.AnyZodObject``z.ZodType`/`z.ZodObject`, `z.any()` object fields made `.optional()` to preserve v3 inference). No runtime behavior change for existing zod 3 users.

apps/supervisor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"prom-client": "^15.1.0",
2424
"socket.io": "4.7.4",
2525
"std-env": "^3.8.0",
26-
"zod": "3.25.76"
26+
"zod": "4.4.3"
2727
},
2828
"devDependencies": {
2929
"@internal/testcontainers": "workspace:*",

apps/webapp/app/components/metrics/QueryWidget.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const chartConfigOptions = {
5555
sortByColumn: z.string().nullable(),
5656
sortDirection: SortDirection,
5757
aggregation: AggregationType,
58-
seriesColors: z.record(z.string()).optional(),
58+
seriesColors: z.record(z.string(), z.string()).optional(),
5959
};
6060

6161
const ChartConfiguration = z.object({ ...chartConfigOptions });

apps/webapp/app/models/orgIntegration.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const SlackSecretSchema = z.object({
2020
refreshToken: z.string().optional(),
2121
botScopes: z.array(z.string()).optional(),
2222
userScopes: z.array(z.string()).optional(),
23-
raw: z.record(z.any()).optional(),
23+
raw: z.record(z.string(), z.any()).optional(),
2424
});
2525

2626
type SlackSecret = z.infer<typeof SlackSecretSchema>;

apps/webapp/app/models/vercelIntegration.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export const VercelSecretSchema = z.object({
151151
teamId: z.string().nullable().optional(),
152152
userId: z.string().optional(),
153153
installationId: z.string().optional(),
154-
raw: z.record(z.any()).optional(),
154+
raw: z.record(z.string(), z.any()).optional(),
155155
});
156156

157157
export type VercelSecret = z.infer<typeof VercelSecretSchema>;

apps/webapp/app/models/vercelSdkRecovery.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ export const VercelSchemas = {
147147
.union([
148148
z
149149
.object({
150-
envs: z.array(z.record(z.unknown())),
150+
envs: z.array(z.record(z.string(), z.unknown())),
151151
pagination: z.unknown().optional(),
152152
})
153153
.passthrough(),
154-
z.array(z.record(z.unknown())),
154+
z.array(z.record(z.string(), z.unknown())),
155155
])
156156
.transform((val) => (Array.isArray(val) ? { envs: val } : val)),
157157

apps/webapp/app/presenters/v3/MetricDashboardPresenter.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const DashboardLayout = z.discriminatedUnion("version", [
4545
z.object({
4646
version: z.literal("1"),
4747
layout: z.array(LayoutItem),
48-
widgets: z.record(Widget),
48+
widgets: z.record(z.string(), Widget),
4949
}),
5050
]);
5151

apps/webapp/app/presenters/v3/SpanPresenter.server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,9 @@ export class SpanPresenter extends BasePresenter {
10041004
filePath: run.lockedBy?.filePath ?? "",
10051005
},
10061006
run: {
1007+
// zod v4 types the run-context `context` (z.any) field as required; it was
1008+
// never populated here (optional under v3), so undefined preserves behavior.
1009+
context: undefined,
10071010
id: run.friendlyId,
10081011
createdAt: run.createdAt,
10091012
tags: run.runTags,

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.environment-variables.new/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const schema = z.object({
9191
}
9292

9393
return;
94-
}, z.array(z.string(), { required_error: "At least one environment is required" })),
94+
}, z.array(z.string(), { error: "At least one environment is required" })),
9595
variables: z.preprocess((i) => {
9696
if (!Array.isArray(i)) {
9797
return [];

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
160160
if (!parsed.success) {
161161
return typedjson(
162162
{
163-
error: parsed.error.errors.map((e) => e.message).join(", "),
163+
error: parsed.error.issues.map((e) => e.message).join(", "),
164164
rows: null,
165165
columns: null,
166166
stats: null,

0 commit comments

Comments
 (0)