Issue: Error: “input.split is not a function (item 0)” in N8N Gmail Node
I’m encountering an error when using N8N’s Gmail node to send an email. The error message is:
“input.split is not a function (item 0)”
Context:
- Node: Gmail node (operation: send email)
- Source: Data is being pulled from a previous node (a database) via the “response” field.
- Error Trigger: The workflow runs fine, but when it gets to the Gmail node, I receive the split error.
- What I’m Using:
- I’m dynamically passing
to
,subject
, andmessage
fields to the Gmail node using expressions like{{$json.message.content.to}}
and others for subject and message. - I have the “Specify Input Schema” option enabled in the email node.
- I’m dynamically passing
Troubleshooting So Far:
- The error seems to indicate that the Gmail node is trying to split a value that isn’t a string (likely
undefined
ornull
). - I’ve verified that some fields, like
bccList
, areundefined
, but they’ve been empty in the past without causing issues. - I attempted hardcoding the
to
,subject
, andmessage
fields with static strings, and the email sends successfully, so the issue seems to lie in how the dynamic data is being passed.
What I’ve Tried:
- Adding fallback values to the fields (e.g.,
{{$json.message.content.to || '[email protected]'}}
) to ensure nothing isundefined
. - Debugging the “response” field, but it seems to contain the expected data structure.
Questions:
- Is this error related to how N8N handles undefined or empty values in specific fields?
- Could the “Specify Input Schema” setting be causing the issue? How should I properly configure it for email nodes?
- Any other troubleshooting tips for preventing this “split” error when passing dynamic data to the Gmail node?
Thanks for your help!
The gmail node: {
“meta”: {
“instanceId”: “36b7251c6ad6e7f498073af8dcd52f607ff829cf47cd1af3ce3282d097429edb”
},
“nodes”: [
{
“parameters”: {
“sendTo”: “={{ $json.message.content.to }}”,
“subject”: “={{ $json.message.content.subject }}”,
“emailType”: “text”,
“message”: “={{ $json.message.content.message }}”,
“options”: {
“appendAttribution”: false,
“bccList”: “={{ $json.message.content.bccList || }}”,
“ccList”: “={{ $json.message.content.ccList || }}”,
“senderName”: “=James, David’s AI Bot”
}
},
“id”: “1dccc81d-ab72-4b57-b82a-b0a51c8d25b1”,
“name”: “Gmail”,
“type”: “n8n-nodes-base.gmail”,
“typeVersion”: 2.1,
“position”: [
1340,
620
],
“credentials”: {
“gmailOAuth2”: {
“id”: “we19m4AKI8reQ2PL”,
“name”: “Gmail account”
}
}
}
],
“connections”: {},
“pinData”: {}
}