Skip to content

🐛 Bug Report: PAYLOAD_VALIDATION_ERROR on optional field #9284

@leonardbinet

Description

@leonardbinet

📜 Description

when triggering an event, on a workflow with payload validation (/v1/events/trigger) an error is thrown when a field has a null value, even if the field is marked as optional:

In this example:
Image

sending a payload without errorMessage will throw:

{"errors":[{"field":"errorMessage","message":"must be string","value":null,"schemaPath":"#/properties/errorMessage/type"}],"schema":{"type":"object","properties":{"email":{"type":"string"},"sourceOrganizationName":{"type":"string"},"targetOrganizationName":{"type":"string"},"isSuccess":{"type":"boolean"},"errorMessage":{"type":"string"}},"required":["email","sourceOrganizationName","targetOrganizationName","isSuccess"]},"type":"PAYLOAD_VALIDATION_ERROR","statusCode":400,"timestamp":"2025-10-02T12:19:59.513Z","path":"/v1/events/trigger","message":"Payload validation failed: errorMessage: must be string","ctx":{"errors":[{"field":"errorMessage","message":"must be string","value":null,"schemaPath":"#/properties/errorMessage/type"}],"schema":{"type":"object","properties":{"email":{"type":"string"},"sourceOrganizationName":{"type":"string"},"targetOrganizationName":{"type":"string"},"isSuccess":{"type":"boolean"},"errorMessage":{"type":"string"}},"required":["email","sourceOrganizationName","targetOrganizationName","isSuccess"]},"type":"PAYLOAD_VALIDATION_ERROR"}}

Shouldn't it pass validation?

👟 Reproduction steps

  1. Set up a workflow with payload schema validation, with an optional field
  2. Trigger workflow with null value on optional field

👍 Expected behavior

It should pass validation

👎 Actual Behavior with Screenshots

It fails:

{"errors":[{"field":"errorMessage","message":"must be string","value":null,"schemaPath":"#/properties/errorMessage/type"}],"schema":{"type":"object","properties":{"email":{"type":"string"},"sourceOrganizationName":{"type":"string"},"targetOrganizationName":{"type":"string"},"isSuccess":{"type":"boolean"},"errorMessage":{"type":"string"}},"required":["email","sourceOrganizationName","targetOrganizationName","isSuccess"]},"type":"PAYLOAD_VALIDATION_ERROR","statusCode":400,"timestamp":"2025-10-02T12:19:59.513Z","path":"/v1/events/trigger","message":"Payload validation failed: errorMessage: must be string","ctx":{"errors":[{"field":"errorMessage","message":"must be string","value":null,"schemaPath":"#/properties/errorMessage/type"}],"schema":{"type":"object","properties":{"email":{"type":"string"},"sourceOrganizationName":{"type":"string"},"targetOrganizationName":{"type":"string"},"isSuccess":{"type":"boolean"},"errorMessage":{"type":"string"}},"required":["email","sourceOrganizationName","targetOrganizationName","isSuccess"]},"type":"PAYLOAD_VALIDATION_ERROR"}}
Image

Novu version

Novu EU Saas

npm version

No response

node version

No response

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions