{"record":{"id":"e46df30c7f3ff1f5","repo":"Zie619/n8n-workflows","slug":"invalid-release-count-releases-length","errorCode":null,"errorMessage":"Invalid release count: ${releases.length}","messagePattern":"Invalid release count: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"workflows/Github/0135_GitHub_Cron_Create_Scheduled.json","lineNumber":59,"sourceCode":"      \"type\": \"n8n-nodes-base.merge\",\n      \"position\": [\n        740,\n        420\n      ],\n      \"parameters\": {},\n      \"typeVersion\": 1,\n      \"id\": \"14000e84-dd29-4a74-b2e6-42eb2d9f0295\",\n      \"notes\": \"This merge node performs automated tasks as part of the workflow.\"\n    },\n    {\n      \"name\": \"No issue for release?\",\n      \"type\": \"n8n-nodes-base.function\",\n      \"position\": [\n        920,\n        420\n      ],\n      \"parameters\": {\n        \"functionCode\": \"const _ = require('lodash')\\n\\n// differentiate merged inputs (didnt find a way to get both inputs into one function invocation)\\nconst releases = _.filter(items, i => _.has(i, 'json.assets'))\\nif (releases.length != 1) throw new Error(`Invalid release count: ${releases.length}`)\\nconst release = releases[0]\\nconst issues = _.without(items, release)\\n//console.log({release,issues})\\n\\n// check if there's an issue for the release\\nconst matchingIssue = _.find(issues, i => i.json.title.includes(release.json.tag_name))\\n//console.log({release,issues,matchingIssue})\\n\\nif (matchingIssue)\\n  return []\\nelse\\n  return [release]\"\n      },\n      \"executeOnce\": false,\n      \"typeVersion\": 1,\n      \"id\": \"55245df8-20a5-4d6c-9ce8-d32dfa0f6764\",\n      \"notes\": \"This function node performs automated tasks as part of the workflow.\"\n    },\n    {\n      \"name\": \"Create issue\",\n      \"type\": \"n8n-nodes-base.gitlab\",\n      \"position\": [\n        1100,\n        420\n      ],\n      \"parameters\": {\n        \"body\": \"={{$json[\\\"url\\\"]}}\\n\\n{{$json[\\\"body\\\"]}}\",\n        \"owner\": \"txlab\",\n        \"title\": \"=Upstream release: {{$json[\\\"tag_name\\\"]}}\",\n        \"labels\": [],","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Github/0135_GitHub_Cron_Create_Scheduled.json#L41-L77","documentation":"Thrown by the legacy Function node 'No issue for release?' in a GitHub-release → GitLab-issue automation. After a Merge node appends GitHub releases and GitLab issues into one items array, the node identifies release items with lodash _.filter(items, i => _.has(i, 'json.assets')) and demands exactly one. Anything other than 1 (zero or multiple) throws with the offending count.","triggerScenarios":"Zero: the GitHub release item lacks a json.assets key (release API response shape changed, or the releases branch fetched something else). Multiple: more than one merged item carries json.assets — e.g. the GitHub trigger fired for several releases in one run, or an issue object happens to contain an assets field. Also: the Merge node mode changed so items from both inputs arrive in separate invocations of the Function node, each seeing a partial list (the code comment admits it could not see both inputs at once).","commonSituations":"n8n version upgrade changing Merge node behavior (append mode now runs the function per-input or batches differently); GitHub payload change dropping the assets array for draft releases; multiple releases created simultaneously; workflow imported into a newer n8n where the legacy Function node runs once per merged branch.","solutions":["Check the Merge node mode — it must be 'Append' so both inputs land in a single Function invocation; in newer n8n versions verify the merged output actually concatenates both branches.","Log the merged items (uncomment console.log) to see whether assets items are 0 or >1 and which shape arrived.","Tighten the release detector to a more unique key than json.assets (e.g. json.tag_name && json.assets, or json.html_url including '/releases/') to avoid false positives from issue items.","If multiple releases per run are legitimate, loop over releases (Split Out / item looping) instead of asserting exactly one."],"exampleFix":"// before\nconst releases = _.filter(items, i => _.has(i, 'json.assets'))\nif (releases.length != 1) throw new Error(`Invalid release count: ${releases.length}`)\nconst release = releases[0]\n\n// after (robust detection, handle 0 explicitly, loop-friendly for >1)\nconst releases = items.filter(i => i.json?.assets && i.json?.tag_name && String(i.json?.html_url || '').includes('/releases/'));\nif (releases.length === 0) throw new Error('No GitHub release item found in merged input');\n// handle each release instead of assuming exactly one\nreturn releases.flatMap(release => {\n  const matchingIssue = items.find(i => i.json?.title?.includes(release.json.tag_name));\n  return matchingIssue ? [] : [release];\n});","handlingStrategy":"validation","validationCode":"const releases = items.filter(i => i.json?.assets && i.json?.tag_name);\nif (releases.length === 0) {\n  // route to an error/notify branch instead of assuming exactly one\n}","typeGuard":"function isGitHubReleaseItem(i) {\n  const j = i?.json;\n  return Boolean(j && Array.isArray(j.assets) && j.tag_name && String(j.html_url || '').includes('/releases/tag/'));\n}","tryCatchPattern":null,"preventionTips":["Detect releases by a compound signature (assets + tag_name + html_url) rather than a single common key like assets.","Confirm the Merge node's Append behavior after every n8n upgrade — legacy Function nodes see items differently across versions.","Handle 0 and >1 releases explicitly (skip or loop) instead of asserting exactly one.","Log merged item shapes during development to catch branch-shape drift early."],"tags":["n8n","github","gitlab","merge-node","legacy-function","lodash"],"backgroundTag":null,"analyzedSha":"94007c1445d9258a7da116646b79473e7c7c3282","analyzedAt":"2026-08-15T04:10:37.591Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}