n8n-io / n8n

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

Postgres node validation fails with 0 #11939

Open ShawnSack opened 2 days ago

ShawnSack commented 2 days ago

Bug Description

I am inserting rows into my database. I have a field with a DECIMAL type and a constraint:

retail_price_per_unit DECIMAL(10,2) NOT NULL
        CONSTRAINT positive_retail_price CHECK (retail_price_per_unit >= 0),

However, when I insert a row where the retail_price_per_unit = 0 I get the following error:

{
  "errorMessage": "Invalid input for 'retail_price_per_unit' [item 3]",
  "errorDescription": "The value \"retail_price_per_unit\" is required but not set",
  "errorDetails": {},
  "n8nDetails": {
    "itemIndex": 3,
    "runIndex": 0,
    "time": "11/27/2024, 5:23:27 PM",
    "n8nVersion": "1.68.0 (Self Hosted)",
    "binaryDataMode": "default",
    "stackTrace": [
      "ExpressionError: Invalid input for 'retail_price_per_unit' [item 3]",
      "    at validateValueAgainstSchema (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/NodeExecuteFunctions.js:1559:15)",
      "    at getNodeParameter (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/NodeExecuteFunctions.js:1681:57)",
      "    at Object.getNodeParameter (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/NodeExecuteFunctions.js:2327:24)",
      "    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Postgres/v2/actions/database/insert.operation.js:172:29)",
      "    at processTicksAndRejections (node:internal/process/task_queues:95:5)",
      "    at Object.router (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Postgres/v2/actions/router.js:50:30)",
      "    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Postgres/v2/PostgresV2.node.js:16:16)",
      "    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:722:19)",
      "    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:704:51",
      "    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1134:20"
    ]
  }
}

My value for item 3: image

To Reproduce

Create table:

CREATE TABLE dummy_table (
  id TEXT PRIMARY KEY,
  retail_price_per_unit DECIMAL(10,2) NOT NULL
        CONSTRAINT positive_retail_price CHECK (retail_price_per_unit >= 0)
);

Create postgres node and attempt to write 0 to retail_price_per_unit.

Expected behavior

0 is a valid input

Operating System

Ubuntu 22.04

n8n Version

1.68.0

Node.js Version

20

Database

PostgreSQL

Execution mode

main (default)

Joffcom commented 2 days ago

Hey @ShawnSack,

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