Zie619/n8n-workflows · error · Error
Invalid action
Error message
Invalid action
What it means
Thrown by 'Verify Approval Data' when `Action` is not exactly 'approve' or 'reject' (case-sensitive). The approval webhook must carry one of these two literal values; anything else - 'Approve', 'approved', 'yes', undefined - fails the includes() check.
Source
Thrown at workflows/Code/0926_Code_Webhook_Create_Webhook.json:1703
"type": "string",
"value": "={{ new Date().toISOString() }}"
}
]
}
},
"typeVersion": 3.4,
"notes": "This set node performs automated tasks as part of the workflow."
},
{
"id": "6749923b-1032-4adb-b805-eda6efd5ee1c",
"name": "Verify Approval Data",
"type": "n8n-nodes-base.code",
"position": [
6340,
4060
],
"parameters": {
"jsCode": "const input = $input.all()[0].json;\nif (!input[\"Submission ID\"]) throw new Error(\"Submission ID is missing\");\nif (![\"approve\", \"reject\"].includes(input[\"Action\"])) throw new Error(\"Invalid action\");\nif (input[\"Action\"] === \"approve\" && input[\"Approved Quantity\"] <= 0) throw new Error(\"Approved quantity must be greater than 0\");\nreturn { json: input };"
},
"typeVersion": 2,
"notes": "This code node performs automated tasks as part of the workflow."
},
{
"id": "c5e34da4-81ec-47dc-aacf-4d6e0cf4256c",
"name": "Retrieve Issue Request Details",
"type": "n8n-nodes-base.googleSheets",
"position": [
6560,
3840
],
"parameters": {
"options": {},
"filtersUI": {
"values": [
{
"lookupValue": "={{ $json[\"Submission ID\"] }}",View on GitHub (pinned to 94007c1445)
Solutions
- Normalize case and trim before validating: input['Action']?.trim().toLowerCase().
- Pin the approval form's allowed values to exactly approve/reject (radio or dropdown, not free text).
- If new actions are legitimate, extend the allowlist and add handling branches for them.
- Echo the received value in the error so mismatches are obvious.
Example fix
// before
if (!["approve", "reject"].includes(input["Action"])) throw new Error("Invalid action");
// after
const action = typeof input["Action"] === 'string' ? input["Action"].trim().toLowerCase() : '';
if (!["approve", "reject"].includes(action)) {
throw new Error(`Invalid action: ${JSON.stringify(input["Action"])} - must be 'approve' or 'reject'`);
} Defensive patterns
Strategy: validation
Validate before calling
const action = typeof input['Action'] === 'string' ? input['Action'].trim().toLowerCase() : '';
if (!['approve', 'reject'].includes(action)) {
throw new Error(`Invalid action: ${JSON.stringify(input['Action'])} - must be 'approve' or 'reject'`);
} Type guard
const isApprovalAction = (v) => typeof v === 'string' && ['approve', 'reject'].includes(v.trim().toLowerCase());
Prevention
- Normalize case and whitespace before the allowlist check
- Use a fixed dropdown/radio (approve|reject) in the approval form
- Echo the received value in the error
- When adding new actions, update the allowlist and routing together
When it happens
Trigger: Approval form sends a different label or capitalized value; Action field missing from the payload; the form was edited to add options like 'hold' or 'return'; email-link based approval encoding the action differently (e.g. 'a'/'r').
Common situations: Form option labels changed after the workflow was built; case mismatch between form values and workflow expectations; new intermediate states added without updating this validator.
Related errors
- Invalid quantity: ${input["Quantity Received"]}
- Invalid price: ${input["Unit Price"]}
- Invalid quantity Requested: ${quantityRequested}. Must be gr
- Product ID is missing
- Invalid quantity requested: ${quantityRequested}
AI-assisted analysis of Zie619/n8n-workflows@94007c1445 (2026-08-15).
Data as JSON: /api/errors/a915b9b37627cc1a.
Report an issue: GitHub.