Zie619/n8n-workflows · error · Error
Invalid release count: ${releases.length}
Error message
Invalid release count: ${releases.length} What it means
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.
Source
Thrown at workflows/Github/0135_GitHub_Cron_Create_Scheduled.json:59
"type": "n8n-nodes-base.merge",
"position": [
740,
420
],
"parameters": {},
"typeVersion": 1,
"id": "14000e84-dd29-4a74-b2e6-42eb2d9f0295",
"notes": "This merge node performs automated tasks as part of the workflow."
},
{
"name": "No issue for release?",
"type": "n8n-nodes-base.function",
"position": [
920,
420
],
"parameters": {
"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]"
},
"executeOnce": false,
"typeVersion": 1,
"id": "55245df8-20a5-4d6c-9ce8-d32dfa0f6764",
"notes": "This function node performs automated tasks as part of the workflow."
},
{
"name": "Create issue",
"type": "n8n-nodes-base.gitlab",
"position": [
1100,
420
],
"parameters": {
"body": "={{$json[\"url\"]}}\n\n{{$json[\"body\"]}}",
"owner": "txlab",
"title": "=Upstream release: {{$json[\"tag_name\"]}}",
"labels": [],View on GitHub (pinned to 94007c1445)
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.
Example fix
// before
const releases = _.filter(items, i => _.has(i, 'json.assets'))
if (releases.length != 1) throw new Error(`Invalid release count: ${releases.length}`)
const release = releases[0]
// after (robust detection, handle 0 explicitly, loop-friendly for >1)
const releases = items.filter(i => i.json?.assets && i.json?.tag_name && String(i.json?.html_url || '').includes('/releases/'));
if (releases.length === 0) throw new Error('No GitHub release item found in merged input');
// handle each release instead of assuming exactly one
return releases.flatMap(release => {
const matchingIssue = items.find(i => i.json?.title?.includes(release.json.tag_name));
return matchingIssue ? [] : [release];
}); Defensive patterns
Strategy: validation
Validate before calling
const releases = items.filter(i => i.json?.assets && i.json?.tag_name);
if (releases.length === 0) {
// route to an error/notify branch instead of assuming exactly one
} Type guard
function isGitHubReleaseItem(i) {
const j = i?.json;
return Boolean(j && Array.isArray(j.assets) && j.tag_name && String(j.html_url || '').includes('/releases/tag/'));
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- One or more input arrays are empty. Check your previous node
- Initial Vector 'data' is undefined or missing.
- Initial Vector 'data' is in an unsupported format.
- AES Key is missing.
- Flow token is missing.
AI-assisted analysis of Zie619/n8n-workflows@94007c1445 (2026-08-15).
Data as JSON: /api/errors/e46df30c7f3ff1f5.
Report an issue: GitHub.