Files
Saadi Myftija a64875a297 fix: regression affecting replayed runs with superjson payloads (#2266)
* Fix regression that broke superjson behavior for the replay flow

* Ignore undefined type metadata when overriding superjson payloads

Addresses https://github.com/triggerdotdev/trigger.dev/issues/1968

* Add a few unit tests for replaceSuperJsonPayload
2025-07-15 12:30:33 +01:00

49 lines
1.0 KiB
TypeScript

import { z } from "zod";
import { RunOptionsData } from "./testTask";
export const ReplayRunData = z
.object({
environment: z.string().optional(),
payload: z
.string()
.optional()
.transform((val, ctx) => {
if (!val) {
return "{}";
}
try {
JSON.parse(val);
return val;
} catch {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "Payload must be a valid JSON string",
});
return z.NEVER;
}
}),
metadata: z
.string()
.optional()
.transform((val, ctx) => {
if (!val) {
return {};
}
try {
return JSON.parse(val);
} catch {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "Metadata must be a valid JSON string",
});
return z.NEVER;
}
}),
failedRedirect: z.string(),
})
.and(RunOptionsData);
export type ReplayRunData = z.infer<typeof ReplayRunData>;