Description
When using Novu Studio to preview workflows, the preview action fails with a 500 error. The error occurs in JSONSchemaFaker's internal validation when generating mock data from Zod schemas.
Environment
- Novu Framework Version: 2.9.0
- Node.js Version: 20.x
- Platform: Windows 11
- Bridge Setup: Encore.ts raw endpoint with Express adapter
Error Details
POST /api/novu?action=preview&workflowId=... 500
Error: Cannot read properties of undefined (reading 'map')
at validateValueForSchema (chunk-ZF4VXELU.js)
at ...JSONSchemaFaker internals...
The error originates from JSONSchemaFaker's validateValueForSchema function when processing certain schema types.
Steps to Reproduce
- Create a workflow with Zod schema validation:
import { workflow } from "@novu/framework";
import { z } from "zod";
const schema = z.object({
userName: z.string().optional().default("there"),
resetUrl: z.string().url(),
expiresInHours: z.number().optional().default(24),
});
export const myWorkflow = workflow(
"my-workflow",
async ({ step, payload }) => {
await step.email("send-email", async () => ({
subject: "Test",
body: "<p>Hello</p>",
}));
},
{ payloadSchema: schema }
);
- Sync workflows to Novu Cloud
- Open Novu Studio and try to preview the workflow
- Preview fails with 500 error
Expected Behavior
Preview should generate mock data from the schema and render the email template.
Actual Behavior
Preview returns 500 error. The JSONSchemaFaker bundled inside @novu/framework fails when calling .map() on an undefined value during schema validation.
Workaround
Direct API calls (via curl/Postman) work correctly. Only the Studio UI preview is affected.
Additional Context
- The error is in the bundled JSONSchemaFaker inside
node_modules/@novu/framework/dist/esm/chunk-ZF4VXELU.js
- The
mock() function calls Pt.generate() (JSONSchemaFaker) which fails on certain schema structures
- Adding
.default() values to Zod schemas does not resolve the issue
Description
When using Novu Studio to preview workflows, the preview action fails with a 500 error. The error occurs in JSONSchemaFaker's internal validation when generating mock data from Zod schemas.
Environment
Error Details
The error originates from JSONSchemaFaker's
validateValueForSchemafunction when processing certain schema types.Steps to Reproduce
Expected Behavior
Preview should generate mock data from the schema and render the email template.
Actual Behavior
Preview returns 500 error. The JSONSchemaFaker bundled inside
@novu/frameworkfails when calling.map()on an undefined value during schema validation.Workaround
Direct API calls (via curl/Postman) work correctly. Only the Studio UI preview is affected.
Additional Context
node_modules/@novu/framework/dist/esm/chunk-ZF4VXELU.jsmock()function callsPt.generate()(JSONSchemaFaker) which fails on certain schema structures.default()values to Zod schemas does not resolve the issue