{"record":{"id":"1f81f73c9c703858","repo":"Zie619/n8n-workflows","slug":"the-video-id-parameter-is-empty-1f81f7","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/1831_Splitout_Code_Automation_Webhook.json","lineNumber":66,"sourceCode":"      \"parameters\": {\n        \"color\": 7,\n        \"width\": 1730,\n        \"height\": 760,\n        \"content\": \"## 🛠️YouTube Video Details & Comments Processing Tool\"\n      },\n      \"typeVersion\": 1,\n      \"notes\": \"This stickyNote node performs automated tasks as part of the workflow.\"\n    },\n    {\n      \"id\": \"454c3494-9808-475d-ad53-decd54d99783\",\n      \"name\": \"Create YouTube API URL\",\n      \"type\": \"n8n-nodes-base.code\",\n      \"position\": [\n        500,\n        100\n      ],\n      \"parameters\": {\n        \"jsCode\": \"// Define the base URL for the YouTube Data API\\nconst BASE_URL = '{{ $env.API_BASE_URL }}';\\n\\n// Get the first input item\\nconst item = $input.first();\\n\\n// Extract the videoId and google_api_key from the input JSON\\nconst VIDEO_ID = item.json.VIDEO_ID;\\nconst GOOGLE_API_KEY = item.json.GOOGLE_API_KEY; // Dynamically retrieve API key\\n\\nif (!VIDEO_ID) {\\n  throw new Error('The video ID parameter is empty.');\\n}\\n\\nif (!GOOGLE_API_KEY) {\\n  throw new Error('The Google API Key is missing.');\\n}\\n\\n// Construct the API URL with the video ID and dynamically retrieved API key\\nconst youtubeUrl = `${BASE_URL}?part=snippet,contentDetails,status,statistics,player,topicDetails&id=${VIDEO_ID}&key=${GOOGLE_API_KEY}`;\\n\\n// Return the constructed URL\\nreturn [\\n  {\\n    json: {\\n      youtubeUrl: youtubeUrl,\\n    },\\n  },\\n];\\n\"\n      },\n      \"typeVersion\": 2,\n      \"notes\": \"This code node performs automated tasks as part of the workflow.\"\n    },\n    {\n      \"id\": \"d715b012-7842-498c-8fda-1b2812b7bc1e\",\n      \"name\": \"Get YouTube Video Details\",\n      \"type\": \"n8n-nodes-base.httpRequest\",\n      \"position\": [\n        700,\n        100\n      ],\n      \"parameters\": {\n        \"url\": \"{{ $env.BASE_URL }}\",\n        \"options\": {}\n      },\n      \"typeVersion\": 4.2,\n      \"notes\": \"This httpRequest node performs automated tasks as part of the workflow.\"","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Splitout/1831_Splitout_Code_Automation_Webhook.json#L48-L84","documentation":"Identical validation to error 100, in a copy of the 'Create YouTube API URL' Code node in an automation-triggered workflow: it takes $input.first(), reads item.json.VIDEO_ID, and throws when falsy before building the YouTube Data API URL. The difference from error 100 is the trigger (automation/webhook chain in file 1831) and node position, not the logic.","triggerScenarios":"The webhook/automation payload that feeds this chain lacks VIDEO_ID, an upstream Split Out emitted an item with an empty ID cell, or the field name/casing differs (video_id, videoID, nested under data.VIDEO_ID).","commonSituations":"Trigger payload schema changed by the calling system, upstream sheet column with blank cells, webhook query param not mapped into json, or manual executions without the trigger data.","solutions":["Execute once with the trigger pinned and log Object.keys($input.first().json) to find the real field name carrying the video ID.","Fix the upstream mapping (webhook 'Include Fields' / Set node) so VIDEO_ID is populated on every item.","Branch items with a missing ID to an error path (IF node) rather than aborting the run for all items.","Accept common casing variants before validating."],"exampleFix":"// before\nconst VIDEO_ID = item.json.VIDEO_ID;\nif (!VIDEO_ID) {\n  throw new Error('The video ID parameter is empty.');\n}\n\n// after\nconst VIDEO_ID = item.json.VIDEO_ID || item.json.video_id || item.json.videoId;\nif (!VIDEO_ID) {\n  throw new Error(`The video ID parameter is empty. Available keys: ${Object.keys(item.json).join(', ')}`);\n}","handlingStrategy":"validation","validationCode":"const item = $input.first();\nconst VIDEO_ID = item.json.VIDEO_ID || item.json.video_id || item.json.videoId;\nif (!VIDEO_ID || !String(VIDEO_ID).trim()) {\n  throw new Error(`VIDEO_ID missing. Keys: ${Object.keys(item.json).join(', ')}`);\n}","typeGuard":"const hasVideoId = (j) => Boolean(j && String(j.VIDEO_ID ?? j.video_id ?? '').trim());","tryCatchPattern":null,"preventionTips":["Pin the automation trigger's payload and assert the VIDEO_ID key exists before enabling the workflow.","Put a Filter node (VIDEO_ID exists and is not empty) between the trigger and the URL-builder node.","Keep one canonical field name for the video ID across all workflows; map once at the entry point."],"tags":["n8n","code-node","validation","youtube-api","required-field"],"backgroundTag":null,"analyzedSha":"94007c1445d9258a7da116646b79473e7c7c3282","analyzedAt":"2026-08-15T04:10:37.591Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}