Zie619/n8n-workflows · error · Error

Input text is empty

Error message

Input text is empty

What it means

Same per-item sentence-splitter Code node as error 95, replicated in workflow 1408. Runs in runOnceForEachItem mode and throws 'Input text is empty' whenever $input.item.json.text is undefined, null, or '' for the current item — one bad item stops the execution.

Source

Thrown at workflows/Splitout/1408_Splitout_Code_Monitor_Triggered.json:25

    "owner": "n8n-user",
    "license": "MIT",
    "category": "automation",
    "status": "active",
    "priority": "high",
    "environment": "production"
  },
  "nodes": [
    {
      "id": "cbc036f7-b0e1-4eb4-94c3-7571c67a1efe",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        -120,
        40
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "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 } };"
      },
      "typeVersion": 2,
      "notes": "This code node performs automated tasks as part of the workflow."
    },
    {
      "id": "faae4740-a529-4275-be0e-b079c3bfde58",
      "name": "Split Out1",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        340,
        -180
      ],
      "parameters": {
        "options": {
          "destinationFieldName": "claim"
        },
        "fieldToSplitOut": "sentences"
      },

View on GitHub (pinned to 94007c1445)

Solutions

  1. Inspect the item's json keys and map the real text field (see exampleFix).
  2. Trim and skip empty items instead of throwing.
  3. Put a Filter node in front to drop empty-text items.
  4. Add .trim() to the check so whitespace-only input is treated as empty.

Example fix

// before
const text = $input.item.json.text;
if (!text) {
 throw new Error('Input text is empty');
}

// after
const text = String($input.item.json.text ?? '').trim();
if (!text) {
  return { json: { sentences: [] } };
}
Defensive patterns

Strategy: validation

Validate before calling

const text = String($input.item.json.text ?? '').trim();
if (!text) {
  return { json: { sentences: [] } }; // skip empty item instead of failing the run
}

Type guard

function isNonEmptyTextItem(item) {
  return typeof item?.json?.text === 'string' && item.json.text.trim().length > 0;
}

Prevention

When it happens

Trigger: An incoming item lacks the text field: content delivered under another key by the trigger, a previous node dropping the field, or a genuinely empty document. Whitespace-only text passes the falsy check but yields an empty sentences array downstream.

Common situations: Trigger type changed (webhook vs manual vs file) with different output keys; mapping expressions referencing a renamed field; empty pages/sections in the input batch; the workflow copied from 0725 into 1408 without updating field names.

Related errors


AI-assisted analysis of Zie619/n8n-workflows@94007c1445 (2026-08-15). Data as JSON: /api/errors/cca85745542b34e8. Report an issue: GitHub.