{"record":{"id":"78b9f33297a8df3e","repo":"Zie619/n8n-workflows","slug":"invalid-quantity-requested-quantityrequested-78b9f3","errorCode":null,"errorMessage":"Invalid quantity requested: ${quantityRequested}","messagePattern":"Invalid quantity requested: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"workflows/Code/0926_Code_Webhook_Create_Webhook.json","lineNumber":1605,"sourceCode":"        6340,\n        3400\n      ],\n      \"parameters\": {\n        \"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 };\"\n      },\n      \"typeVersion\": 2,\n      \"notes\": \"This code node performs automated tasks as part of the workflow.\"\n    },\n    {\n      \"id\": \"6d88db70-6b4f-47c5-8093-ab339762edbe\",\n      \"name\": \"Verify Requested Quantity\",\n      \"type\": \"n8n-nodes-base.code\",\n      \"position\": [\n        6560,\n        3400\n      ],\n      \"parameters\": {\n        \"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 };\"\n      },\n      \"typeVersion\": 2,\n      \"notes\": \"This code node performs automated tasks as part of the workflow.\"\n    },\n    {\n      \"id\": \"bd2313cc-e3c9-4405-a1ed-8f64969e5bca\",\n      \"name\": \"Check Available Stock for Issue\",\n      \"type\": \"n8n-nodes-base.googleSheets\",\n      \"position\": [\n        7000,\n        3240\n      ],\n      \"parameters\": {\n        \"options\": {},\n        \"filtersUI\": {\n          \"values\": [\n            {\n              \"lookupValue\": \"={{ $json[\\\"Product ID\\\"] }}\",","sourceCodeStart":1587,"sourceCodeEnd":1623,"githubUrl":"https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Code/0926_Code_Webhook_Create_Webhook.json#L1587-L1623","documentation":"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.","triggerScenarios":"Quantity Requested submitted as 0, '0', '', or a negative number; typo like '-5'; draft/preview submissions with placeholder zeros.","commonSituations":"Form quantity field defaults to 0 and submitter does not change it; no min constraint client-side; negative values from manual API testing.","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."],"exampleFix":"// before\nconst quantityRequested = input[\"Quantity Requested\"];\nif (quantityRequested <= 0) throw new Error(`Invalid quantity requested: ${quantityRequested}`);\n\n// after\nconst quantityRequested = Number(input[\"Quantity Requested\"]);\nif (!Number.isFinite(quantityRequested) || quantityRequested <= 0) {\n  throw new Error(`Invalid quantity requested: ${JSON.stringify(input[\"Quantity Requested\"])} - must be a number > 0`);\n}","handlingStrategy":"validation","validationCode":"const quantityRequested = Number(input['Quantity Requested']);\nif (!Number.isFinite(quantityRequested) || quantityRequested <= 0) {\n  throw new Error(`Invalid quantity requested: ${JSON.stringify(input['Quantity Requested'])} - must be > 0`);\n}","typeGuard":"const isValidRequestedQty = (v) => {\n  const n = Number(v);\n  return Number.isFinite(n) && n > 0;\n};","tryCatchPattern":null,"preventionTips":["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"],"tags":["n8n","webhook","validation","inventory","type-coercion"],"backgroundTag":null,"analyzedSha":"94007c1445d9258a7da116646b79473e7c7c3282","analyzedAt":"2026-08-15T04:10:37.591Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}