Zie619/n8n-workflows · error · Error

Invalid quantity requested: ${quantityRequested}

Error message

Invalid quantity requested: ${quantityRequested}

What it means

Thrown by 'Verify Requested Quantity' when `Quantity Requested` is <= 0. Same node as error 35; this guard runs second, after the Product ID check, so reaching it means the payload had a Product ID but a non-positive quantity. Raw comparison means '0' and '' throw while NaN values (undefined, 'abc') slip through.

Source

Thrown at workflows/Code/0926_Code_Webhook_Create_Webhook.json:1605

        6340,
        3400
      ],
      "parameters": {
        "jsCode": "const input = $input.all()[0].json;\nconst quantityRequested= input[\"Quantity Requested\"];\n\nif (quantityRequested <= 0) throw new Error(`Invalid quantity Requested: ${quantityRequested}. Must be greater than 0`);\n\nreturn { json: input };"
      },
      "typeVersion": 2,
      "notes": "This code node performs automated tasks as part of the workflow."
    },
    {
      "id": "6d88db70-6b4f-47c5-8093-ab339762edbe",
      "name": "Verify Requested Quantity",
      "type": "n8n-nodes-base.code",
      "position": [
        6560,
        3400
      ],
      "parameters": {
        "jsCode": "const input = $input.all()[0].json;\nconst quantityRequested = input[\"Quantity Requested\"];\nif (!input[\"Product ID\"]) throw new Error(\"Product ID is missing\");\nif (quantityRequested <= 0) throw new Error(`Invalid quantity requested: ${quantityRequested}`);\nif (!input[\"Submission ID\"]) throw new Error(\"Submission ID is missing\");\nreturn { json: input };"
      },
      "typeVersion": 2,
      "notes": "This code node performs automated tasks as part of the workflow."
    },
    {
      "id": "bd2313cc-e3c9-4405-a1ed-8f64969e5bca",
      "name": "Check Available Stock for Issue",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        7000,
        3240
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json[\"Product ID\"] }}",

View on GitHub (pinned to 94007c1445)

Solutions

  1. Parse to a number and require Number.isFinite(n) && n > 0.
  2. Set min=1 and required on the form's quantity input.
  3. Return an actionable message to the requester (via the webhook response) instead of a bare throw.
  4. Add the same guard earlier at form-submission time so bad data never reaches n8n.

Example fix

// before
const quantityRequested = input["Quantity Requested"];
if (quantityRequested <= 0) throw new Error(`Invalid quantity requested: ${quantityRequested}`);

// after
const quantityRequested = Number(input["Quantity Requested"]);
if (!Number.isFinite(quantityRequested) || quantityRequested <= 0) {
  throw new Error(`Invalid quantity requested: ${JSON.stringify(input["Quantity Requested"])} - must be a number > 0`);
}
Defensive patterns

Strategy: validation

Validate before calling

const quantityRequested = Number(input['Quantity Requested']);
if (!Number.isFinite(quantityRequested) || quantityRequested <= 0) {
  throw new Error(`Invalid quantity requested: ${JSON.stringify(input['Quantity Requested'])} - must be > 0`);
}

Type guard

const isValidRequestedQty = (v) => {
  const n = Number(v);
  return Number.isFinite(n) && n > 0;
};

Prevention

When it happens

Trigger: Quantity Requested submitted as 0, '0', '', or a negative number; typo like '-5'; draft/preview submissions with placeholder zeros.

Common situations: Form quantity field defaults to 0 and submitter does not change it; no min constraint client-side; negative values from manual API testing.

Related errors


AI-assisted analysis of Zie619/n8n-workflows@94007c1445 (2026-08-15). Data as JSON: /api/errors/78b9f33297a8df3e. Report an issue: GitHub.