{"record":{"id":"6e409780c9dce7c6","repo":"Zie619/n8n-workflows","slug":"the-video-id-parameter-is-empty-6e4097","errorCode":null,"errorMessage":"The video ID parameter is empty.","messagePattern":"The video ID parameter is empty\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"workflows/Splitout/1463_Splitout_Code_Automate_Webhook.json","lineNumber":33,"sourceCode":"  \"name\": \"⚡📽️ Ultimate AI-Powered Chatbot for YouTube Summarization & Analysis\",\n  \"tags\": [\n    \"automation\",\n    \"n8n\",\n    \"production-ready\",\n    \"excellent\",\n    \"optimized\"\n  ],\n  \"nodes\": [\n    {\n      \"id\": \"10cfb27f-ef93-41cd-972e-37dfdcab97ad\",\n      \"name\": \"Get YouTube Transcript\",\n      \"type\": \"n8n-nodes-base.code\",\n      \"position\": [\n        20,\n        360\n      ],\n      \"parameters\": {\n        \"jsCode\": \"// Get all input items\\nconst items = $input.all();\\nconst results = [];\\n\\n// Import the YoutubeTranscript module from the youtube-transcript package\\n// npm i -g youtube-transcript\\nconst { YoutubeTranscript } = require('youtube-transcript');\\n\\nfor (let i = 0; i < items.length; i++) {\\n  // Extract the VIDEO_ID from the input JSON\\n  const VIDEO_ID = items[i].json.VIDEO_ID;\\n  \\n  if (!VIDEO_ID) {\\n    throw new Error('The video ID parameter is empty.');\\n  }\\n  \\n  try {\\n    // Fetch the transcript for the provided video ID\\n    const transcript = await YoutubeTranscript.fetchTranscript(VIDEO_ID);\\n    \\n    // Append the fetched transcript data to the results\\n    results.push({\\n      json: {\\n        youtubeId: VIDEO_ID,\\n        transcript,\\n      },\\n    });\\n  } catch (error) {\\n    // In case of an error, add an error message to the output for this item\\n    results.push({\\n      json: {\\n        youtubeId: VIDEO_ID,\\n        error: error.message,\\n      },\\n    });\\n  }\\n}\\n\\n// Return the results to be used by the next node in the workflow\\nreturn results;\\n\"\n      },\n      \"typeVersion\": 2,\n      \"notes\": \"This code node performs automated tasks as part of the workflow.\"\n    },\n    {\n      \"id\": \"a7b7740e-7470-4ce0-a698-6043559eb781\",\n      \"name\": \"When Executed by Another Workflow\",\n      \"type\": \"n8n-nodes-base.executeWorkflowTrigger\",\n      \"position\": [\n        -580,\n        180\n      ],\n      \"parameters\": {\n        \"inputSource\": \"jsonExample\",\n        \"jsonExample\": \"{\\n  \\\"query\\\": {\\n\\t\\\"videoId\\\": \\\"YouTube video id\\\"\\n  }\\n}\"\n      },\n      \"typeVersion\": 1.1,\n      \"notes\": \"This executeWorkflowTrigger node performs automated tasks as part of the workflow.\"","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Splitout/1463_Splitout_Code_Automate_Webhook.json#L15-L51","documentation":"Thrown by 'Get YouTube Transcript' (workflow 1463). It loops over $input.all() and throws when an item's json.VIDEO_ID is falsy — the key is absent, undefined, null, or empty string. Note the asymmetry: a present-but-wrong ID does not throw here; it is caught and returned as an error field, so this message strictly means 'the VIDEO_ID field itself is missing/empty'.","triggerScenarios":"The 'When Executed by Another Workflow' executeWorkflowTrigger received a payload without VIDEO_ID — the calling workflow passes a differently-named key (videoId, video_id, url) or an empty value. Because the throw is inside the loop, the first item missing the field aborts the run even if later items are fine.","commonSituations":"Parent workflow's payload schema drifted from this sub-workflow (videoId vs VIDEO_ID); caller passing a full YouTube URL where the child expects the bare 11-char ID; a test execution with no input data; items coming from a form/upload where the field was optional.","solutions":["Check what the parent workflow sends to the executeWorkflowTrigger and align the key to VIDEO_ID (see exampleFix).","Normalize common variants before validating: videoId, video_id, or extracting the ID from a URL.","Skip or report bad items instead of throwing so one missing ID does not kill the batch.","Pin a sample trigger payload containing VIDEO_ID for local testing."],"exampleFix":"// before\nconst VIDEO_ID = items[i].json.VIDEO_ID;\nif (!VIDEO_ID) {\n  throw new Error('The video ID parameter is empty.');\n}\n\n// after\nconst j = items[i].json;\nlet VIDEO_ID = j.VIDEO_ID || j.videoId || j.video_id || '';\nif (!VIDEO_ID && typeof j.url === 'string') {\n  VIDEO_ID = (j.url.match(/(?:v=|youtu\\.be\\/|shorts\\/)([\\w-]{11})/) || [])[1] || '';\n}\nif (!VIDEO_ID) {\n  results.push({ json: { error: 'The video ID parameter is empty.', index: i } });\n  continue;\n}","handlingStrategy":"validation","validationCode":"const j = items[i].json;\nlet VIDEO_ID = j.VIDEO_ID || j.videoId || j.video_id || '';\nif (!VIDEO_ID && typeof j.url === 'string') {\n  VIDEO_ID = (j.url.match(/(?:v=|youtu\\.be\\/|shorts\\/)([\\w-]{11})/) || [])[1] || '';\n}\nif (!VIDEO_ID) { results.push({ json: { error: 'video ID empty', index: i } }); continue; }","typeGuard":"function isYoutubeId(v) {\n  return typeof v === 'string' && /^[\\w-]{11}$/.test(v);\n}","tryCatchPattern":null,"preventionTips":["Agree on one payload schema (VIDEO_ID) between calling and sub-workflows, and pin a sample payload.","Accept common variants (videoId, video_id, full URL) and normalize in one place.","Push per-item errors into results instead of throwing so one bad ID does not kill a batch."],"tags":["n8n","youtube","sub-workflow","input-validation","field-mapping"],"backgroundTag":null,"analyzedSha":"94007c1445d9258a7da116646b79473e7c7c3282","analyzedAt":"2026-08-15T04:10:37.591Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}