{"record":{"id":"a6544523741ef69c","repo":"Zie619/n8n-workflows","slug":"input-text-is-empty","errorCode":null,"errorMessage":"Input text is empty","messagePattern":"Input text is empty","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"workflows/Splitout/0725_Splitout_Code_Update_Triggered.json","lineNumber":25,"sourceCode":"    \"owner\": \"n8n-user\",\n    \"license\": \"MIT\",\n    \"category\": \"automation\",\n    \"status\": \"active\",\n    \"priority\": \"high\",\n    \"environment\": \"production\"\n  },\n  \"nodes\": [\n    {\n      \"id\": \"cbc036f7-b0e1-4eb4-94c3-7571c67a1efe\",\n      \"name\": \"Code\",\n      \"type\": \"n8n-nodes-base.code\",\n      \"position\": [\n        -120,\n        40\n      ],\n      \"parameters\": {\n        \"mode\": \"runOnceForEachItem\",\n        \"jsCode\": \"// Get the input text\\nconst text = $input.item.json.text;\\n\\n// Ensure text is not null or undefined\\nif (!text) {\\n  throw new Error('Input text is empty');\\n}\\n\\n// Function to split text into sentences while preserving dates and list items\\nfunction splitIntoSentences(text) {\\n  const monthNames = '(?:Januar|Februar|März|April|Mai|Juni|Juli|August|September|Oktober|November|Dezember)';\\n  const datePattern = `(?:\\\\\\\\d{1,2}\\\\\\\\.\\\\\\\\s*(?:${monthNames}|\\\\\\\\d{1,2}\\\\\\\\.)\\\\\\\\s*\\\\\\\\d{2,4})`;\\n  \\n  // Split by sentence-ending punctuation, but not within dates or list items\\n  const regex = new RegExp(`(?<=[.!?])\\\\\\\\s+(?=[A-ZÄÖÜ]|$)(?!${datePattern}|\\\\\\\\s*[-•]\\\\\\\\s)`, 'g');\\n  \\n  return text.split(regex)\\n    .map(sentence => sentence.trim())\\n    .filter(sentence => sentence !== '');\\n}\\n\\n// Split the text into sentences\\nconst sentences = splitIntoSentences(text);\\n\\n// Output a single object with an array of sentences\\nreturn { json: { sentences: sentences } };\"\n      },\n      \"typeVersion\": 2,\n      \"notes\": \"This code node performs automated tasks as part of the workflow.\"\n    },\n    {\n      \"id\": \"faae4740-a529-4275-be0e-b079c3bfde58\",\n      \"name\": \"Split Out1\",\n      \"type\": \"n8n-nodes-base.splitOut\",\n      \"position\": [\n        340,\n        -180\n      ],\n      \"parameters\": {\n        \"options\": {\n          \"destinationFieldName\": \"claim\"\n        },\n        \"fieldToSplitOut\": \"sentences\"\n      },","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Splitout/0725_Splitout_Code_Update_Triggered.json#L7-L43","documentation":"Thrown by the runOnceForEachItem 'Code' node (workflow 0725). For each incoming item it reads $input.item.json.text and throws when it is falsy — undefined, null, or empty string. Because the node runs per item, one bad item among many aborts the whole execution at that item.","triggerScenarios":"An upstream item simply has no text field: the source node puts content under a different key (content, body, description, plain text of an email/PDF), or the document was genuinely empty. Whitespace-only strings ('  ') pass the check but then produce zero sentences downstream.","commonSituations":"Gmail/PDF/RSS trigger renamed output fields between n8n versions; a previous Set node mapping $('text') against a missing field yielding undefined; empty attachments or blank documents in the batch; German-language sentence splitter receiving items from a filter that dropped the text field.","solutions":["Inspect the upstream item's json keys and read the text from the correct field (see exampleFix).","Trim before checking so whitespace-only input is caught, and skip empty items instead of throwing.","Add a Filter node (text is not empty) before this Code node.","If text can legitimately be empty, return an empty sentences array rather than failing the run."],"exampleFix":"// before\nconst text = $input.item.json.text;\nif (!text) {\n  throw new Error('Input text is empty');\n}\n\n// after\nconst text = ($input.item.json.text ?? $input.item.json.content ?? '').trim();\nif (!text) {\n  return { json: { sentences: [], skipped: 'empty text' } };\n}","handlingStrategy":"validation","validationCode":"const text = String($input.item.json.text ?? $input.item.json.content ?? '').trim();\nif (!text) {\n  return { json: { sentences: [], skipped: true } };\n}","typeGuard":"function hasText(item) {\n  const t = item?.json?.text;\n  return typeof t === 'string' && t.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Put a Filter node (text is not empty) ahead of per-item text processing.","Trim before the emptiness check so whitespace-only documents are caught.","Map the correct source field once at the trigger instead of assuming 'text' everywhere."],"tags":["n8n","text-processing","empty-input","runonceforeachitem","field-mapping"],"backgroundTag":null,"analyzedSha":"94007c1445d9258a7da116646b79473e7c7c3282","analyzedAt":"2026-08-15T04:10:37.591Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}