Zie619/n8n-workflows · error · Error

One or more input arrays are empty. Check your previous node

Error message

One or more input arrays are empty. Check your previous nodes.

What it means

Thrown by the 'Select Random Video, Music & Quote' Code node after a Merge node combines three source branches. It partitions merged items by marker fields (BackgroundURL for videos, MusicURL for music, Qoute for quotes) and requires all three partitions to be non-empty before randomly selecting one of each. Note the misspelled marker 'Qoute' is part of the contract.

Source

Thrown at workflows/Code/1864_Code_Executecommand_Create_Webhook.json:314

        740,
        200
      ],
      "parameters": {
        "numberInputs": 3
      },
      "typeVersion": 3,
      "notes": "This merge node performs automated tasks as part of the workflow."
    },
    {
      "id": "28c79ad7-cb34-424a-97ed-fcec5471e179",
      "name": "Select Random Video, Music & Quote",
      "type": "n8n-nodes-base.code",
      "position": [
        940,
        200
      ],
      "parameters": {
        "jsCode": "function getRandomItem(arr) {\n  return arr[Math.floor(Math.random() * arr.length)];\n}\n\n// Filter items based on unique keys from the merged inputs\nconst videoItems = items.filter(item => item.json.BackgroundURL !== undefined);\nconst musicItems = items.filter(item => item.json.MusicURL !== undefined);\nconst quoteItems = items.filter(item => item.json.Qoute !== undefined);\n\n// Debug logs to check counts in the execution log\nconsole.log(\"Video Items count: \" + videoItems.length);\nconsole.log(\"Music Items count: \" + musicItems.length);\nconsole.log(\"Quote Items count: \" + quoteItems.length);\n\nif (videoItems.length === 0 || musicItems.length === 0 || quoteItems.length === 0) {\n  throw new Error(\"One or more input arrays are empty. Check your previous nodes.\");\n}\n\nconst selectedVideo = getRandomItem(videoItems);\nconst selectedMusic = getRandomItem(musicItems);\nconst selectedQuote = getRandomItem(quoteItems);\n\n// Return the combined selected items\nreturn [{\n  video: selectedVideo.json,\n  music: selectedMusic.json,\n  quote: selectedQuote.json\n}];\n"
      },
      "typeVersion": 2,
      "notes": "This code node performs automated tasks as part of the workflow."
    },
    {
      "id": "bd3fa420-555d-46a2-b48c-15a916f62b44",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -20,
        -120
      ],
      "parameters": {
        "width": 1100,
        "height": 660,
        "content": "## Data Preparation & File Selection\nRetrieve and merge source data for quotes, video backgrounds, and music from Google Sheets and Google Drive; then randomly select one quote, one background video, and one music file."
      },
      "typeVersion": 1,

View on GitHub (pinned to 94007c1445)

Solutions

  1. Read the debug log lines 'Video Items count / Music Items count / Quote Items count' in the execution to identify which partition is empty.
  2. Check that branch's upstream nodes (sheet rows present? filter conditions not excluding everything?).
  3. Verify the marker field names and casing match exactly, including the intentional misspelling 'Qoute' (or fix the spelling everywhere consistently: node filter + error 50's reader).
  4. Refill or un-exclude the empty source, or add an IF branch that alerts a human when any source runs dry instead of throwing.

Example fix

// before
if (videoItems.length === 0 || musicItems.length === 0 || quoteItems.length === 0) {
  throw new Error("One or more input arrays are empty. Check your previous nodes.");
}

// after (explicit diagnosis)
const counts = { video: videoItems.length, music: musicItems.length, quote: quoteItems.length };
const empty = Object.entries(counts).filter(([, n]) => n === 0).map(([k]) => k);
if (empty.length) {
  throw new Error(`Empty input branch(es): ${empty.join(', ')}. Counts: ${JSON.stringify(counts)}`);
}
Defensive patterns

Strategy: validation

Validate before calling

const counts = {
  video: items.filter(i => i.json.BackgroundURL !== undefined).length,
  music: items.filter(i => i.json.MusicURL !== undefined).length,
  quote: items.filter(i => i.json.Qoute !== undefined).length
};
const ready = counts.video > 0 && counts.music > 0 && counts.quote > 0;

Type guard

function hasAllSources(items) {
  const has = k => items.some(i => i.json && i.json[k] !== undefined);
  return has('BackgroundURL') && has('MusicURL') && has('Qoute');
}

Prevention

When it happens

Trigger: Any of the three upstream branches returned zero items or returned items lacking its marker field: the videos source produced no BackgroundURL items, the music source no MusicURL items, or the quotes source no 'Qoute' items. Also fires when the Merge node mode drops a branch (e.g. 'Append' with one empty input) or when a marker field is renamed upstream ('Quote' instead of 'Qoute').

Common situations: A Google Sheets/Dropbox source sheet filtered to empty by a date or status condition; an upstream HTTP/regex extraction node returning no rows so its branch contributes nothing; field renamed in the source data ('Quote' spelled correctly) breaking the filter; Merge node mode changed from Append to something that suppresses empty branches differently.

Related errors


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