n8n-io / n8n

Free and source-available fair-code licensed workflow automation tool. Easily automate tasks across different services.
https://n8n.io
Other
45.52k stars 6.27k forks source link

Information Extractor Node Fails to Validate Date Format Due to Zod Version Compatibility #10349

Open stwonary opened 1 month ago

stwonary commented 1 month ago

Bug Description

I'm encountering an issue with the Information Extractor node. The problem arises when attempting to validate a date field using the format: "date" option within the node's schema. The issue seems to be related to the version of Zod currently used by n8n, which is 3.22.4. This version of Zod does not support date format validation, which is a feature introduced in Zod version 3.23.0. This incompatibility is causing the date format validation to fail.

To Reproduce

  1. Create a Workflow:

    • In n8n version 1.54.0, start by creating a new workflow.
  2. Add the Information Extractor Node:

    • Incorporate an Information Extractor node into the workflow.
  3. Define the Schema:

    • Within the Information Extractor node, define the following schema that includes a start_date field:
      {
      "start_date": {
      "type": "string",
      "format": "date",
      "description": "Start date of availability"
      }
      }
  4. Execute the Workflow:

    • Run the workflow to observe the behavior.

Observed Error:

Upon execution, the following error message is encountered:

z.string(...).date is not a function [line 5]
TypeError

This issue arises because the zod version currently used in n8n (v3.22.4) does not support the date format in schemas. Support for this feature was introduced in zod version v3.23.0.

For more details, refer to the related issue on GitHub: Zod Issue #3387.

Expected behavior

The Information Extractor node should successfully validate the start_date field as a date, given the format: "date" specification in the schema.

Operating System

Alpine Linux v3.20

n8n Version

1.52.0

Node.js Version

20.15.0

Database

PostgreSQL

Execution mode

queue

Joffcom commented 1 month ago

Hey @stwonary,

We have created an internal ticket to look into this which we will be tracking as "GHC-149"

janober commented 2 weeks ago

Fix got released with n8n@1.57.0