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
- Parse to a number and require Number.isFinite(n) && n > 0.
- Set min=1 and required on the form's quantity input.
- Return an actionable message to the requester (via the webhook response) instead of a bare throw.
- 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
- Parse to Number first so NaN and empty strings are caught, not just <= 0
- Default the form quantity away from 0 (or block submit at 0)
- Give the requester an actionable error response
- Share one quantity validator across request and approval branches
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
- Invalid quantity Requested: ${quantityRequested}. Must be gr
- Product ID is missing
- Insufficient stock for ${$('Retrieve Issue Request Details')
- Invalid quantity: ${input["Quantity Received"]}
- Submission ID is missing
AI-assisted analysis of Zie619/n8n-workflows@94007c1445 (2026-08-15).
Data as JSON: /api/errors/78b9f33297a8df3e.
Report an issue: GitHub.