Describe the problem/error/question
The Code node (JavaScript) isn’t working as expected on our n8n Cloud pro plan. It isn’t able to access previous node outputs using $('NodeName').item.json.variable
syntax.
I’ve tried drag-and-dropping the variable into the code, using autocomplete to generate the path in the code, and these both match (same code generated) - and the code intellisense agrees that the code is correct (no errors or red squiggly lines).
I’ve also tested this exact code successfully on a self-hosted n8n instance with no errors.
This code works if I remove the reference to $(‘Aggregate’). I have extensively tested this with other references from previous nodes as well - all are broken right now. (I’m a software engineer)
What is the error message (if any)?
“Unknown Error”
Error: Unknown error at JsTaskRunnerSandbox.throwExecutionError (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/JsTaskRunnerSandbox.js:55:19) at JsTaskRunnerSandbox.runCodeForEachItem (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/JsTaskRunnerSandbox.js:44:29) at processTicksAndRejections (node:internal/process/task_queues:95:5) at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/Code.node.js:107:20) at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/workflow-execute.js:681:27) at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/workflow-execute.js:913:51 at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/workflow-execute.js:1246:20
Please share your workflow
Share the output returned by the last node
The direct input:
[
{
"output": {
"reasoning": "The email is a congratulatory message. It does not require personal attention as it is positive communication between colleagues. I will add the label 'Sorted by AI' for organization and remove 'INBOX' and 'IMPORTANT' labels accordingly. No other specific labels are applicable.",
"add": [
"Sorted by AI"
],
"remove": [
"INBOX",
"IMPORTANT"
]
}
},
{
"output": {
"reasoning": "The email is a follow-up regarding a technical aspect of a transfer which does not require personal attention. Therefore, the INBOX and IMPORTANT labels are removed. Labels 'Sorted by AI' will be added for organization. No specific labels like 'Leadership', 'Hiring & Recruiting', or 'Receipts' apply to this email.",
"add": [
"Sorted by AI"
],
"remove": [
"INBOX",
"IMPORTANT"
]
}
},
{},
{
"output": {
"reasoning": "The email is a follow-up about Multi-factor authentication enforcement from a vendor, which is informational and doesn't require personal attention. Therefore, both 'INBOX' and 'IMPORTANT' labels can be removed. The 'Sorted by AI' label will be added to aid organization, along with 'System Alerts' as it relates to a security measure that may impact the user's access to services.",
"add": [
"Sorted by AI",
"System Alerts"
],
"remove": [
"INBOX",
"IMPORTANT"
]
}
},
{
"output": {
"reasoning": "This email is discussing a product update. Since it doesn't require direct personal attention, the INBOX and IMPORTANT labels should be removed. The 'Sorted by AI' label needs to be added for organization purposes. No other relevant labels are applicable, resulting in a cleaner inbox.",
"add": [
"Sorted by AI"
],
"remove": [
"INBOX",
"IMPORTANT"
]
}
}
]
And the $(‘Aggregate’) data:
[
{
"gmail_labels": [
{
"id": "CHAT",
"name": "CHAT"
},
{
"id": "SENT",
"name": "SENT"
},
{
"id": "INBOX",
"name": "INBOX"
},
{
"id": "IMPORTANT",
"name": "IMPORTANT"
},
{
"id": "TRASH",
"name": "TRASH"
},
{
"id": "DRAFT",
"name": "DRAFT"
},
{
"id": "SPAM",
"name": "SPAM"
},
{
"id": "CATEGORY_FORUMS",
"name": "CATEGORY_FORUMS"
},
{
"id": "CATEGORY_UPDATES",
"name": "CATEGORY_UPDATES"
},
{
"id": "CATEGORY_PERSONAL",
"name": "CATEGORY_PERSONAL"
},
{
"id": "CATEGORY_PROMOTIONS",
"name": "CATEGORY_PROMOTIONS"
},
{
"id": "CATEGORY_SOCIAL",
"name": "CATEGORY_SOCIAL"
},
{
"id": "STARRED",
"name": "STARRED"
},
{
"id": "UNREAD",
"name": "UNREAD"
},
{
"id": "Label_1623606469233510674",
"name": "Receipts"
},
{
"id": "Label_3076778126379818076",
"name": "Industry News & Trends"
},
{
"id": "Label_3322092101721916598",
"name": "Customer Issues"
},
{
"id": "Label_3828794275064901130",
"name": "Newsletter"
}
]
}
]
Information on your n8n setup
- n8n version: 1.83.2 (Stable)
- Database (default: SQLite): Default
- n8n EXECUTIONS_PROCESS setting (default: own, main): Default
- Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
- Operating system: n8n cloud