From 269879fe0958c1b9101dc5bdfd789c69e2c7f05b Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> Date: Fri, 8 Nov 2024 20:43:21 +0200 Subject: [PATCH] fix(core): Handle item and items correctly in js task runner --- .../built-ins-parser/__tests__/built-ins-parser.test.ts | 9 +++++++++ .../js-task-runner/built-ins-parser/built-ins-parser.ts | 3 +++ 2 files changed, 12 insertions(+) diff --git a/packages/@n8n/task-runner/src/js-task-runner/built-ins-parser/__tests__/built-ins-parser.test.ts b/packages/@n8n/task-runner/src/js-task-runner/built-ins-parser/__tests__/built-ins-parser.test.ts index 366a9188de..d64c154884 100644 --- a/packages/@n8n/task-runner/src/js-task-runner/built-ins-parser/__tests__/built-ins-parser.test.ts +++ b/packages/@n8n/task-runner/src/js-task-runner/built-ins-parser/__tests__/built-ins-parser.test.ts @@ -62,6 +62,15 @@ describe('BuiltInsParser', () => { expect(state).toEqual(new BuiltInsParserState({ needs$input: true })); }); + + test.each([['items'], ['item']])( + 'should mark input as needed when %s is used', + (identifier) => { + const state = parseAndExpectOk(`return ${identifier};`); + + expect(state).toEqual(new BuiltInsParserState({ needs$input: true })); + }, + ); }); describe('$(...)', () => { diff --git a/packages/@n8n/task-runner/src/js-task-runner/built-ins-parser/built-ins-parser.ts b/packages/@n8n/task-runner/src/js-task-runner/built-ins-parser/built-ins-parser.ts index dd2d849c6a..7bdfff8240 100644 --- a/packages/@n8n/task-runner/src/js-task-runner/built-ins-parser/built-ins-parser.ts +++ b/packages/@n8n/task-runner/src/js-task-runner/built-ins-parser/built-ins-parser.ts @@ -131,6 +131,9 @@ export class BuiltInsParser { state.markExecutionAsNeeded(); } else if (node.name === '$prevNode') { state.markPrevNodeAsNeeded(); + } else if (node.name === 'items' || node.name === 'item') { + // item is deprecated but we still need to support it + state.markInputAsNeeded(); } };