-
Notifications
You must be signed in to change notification settings - Fork 8.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Merge Node): Fixing how paired items are handled in the merge node, when choosing a branch and selecting to return an empty object #8479
Conversation
This happens only when choosing a branch and selecting to return an empty object. I stumbled on this while attempting to solve the level 2 course.
c00c8db
to
26c00b1
Compare
// TODO: was necessary to satisfies types. | ||
// I'm wondering if there is already a function that does exactly that? That turns | ||
// Array<IPairedItemData | IPairedItemData[] | number | undefined> -> IPairedItemData[] | ||
// or | ||
// IPairedItemData | IPairedItemData[] | number | undefined -> IPairedItemData | undefined | ||
function numberToPairedItem( | ||
possiblyPairedItems: Array<INodeExecutionData['pairedItem']>, | ||
): IPairedItemData[] { | ||
return possiblyPairedItems.reduce((pairedItems: IPairedItemData[], pairedItem) => { | ||
if (typeof pairedItem === 'number') { | ||
pairedItems.push({ item: pairedItem }); | ||
} else if (Array.isArray(pairedItem)) { | ||
pairedItems.push(...pairedItem); | ||
} else if (pairedItem) { | ||
pairedItems.push(pairedItem); | ||
} | ||
|
||
return pairedItems; | ||
}, [] as IPairedItemData[]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to do this?
Does this helper exist anywhere? If not, should I move it to some utility module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@despairblue I guess if this is something that may come up again it would be handy to have a utility function for it so we can reuse it but I am not sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Joffcom There was a function already that does this, just had to combine it with a flatMap :)
…d-items-being-broken-merge-node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
✅ All Cypress E2E specs passed |
1 flaky test on run #4088 ↗︎
Details:
cypress/e2e/5-ndv.cy.ts • 1 flaky test
Review all test suite changes for PR #8479 ↗︎ |
Got released with |
…e, when choosing a branch and selecting to return an empty object (#8479) Co-authored-by: Michael Kret <[email protected]>
Summary
Referencing items before a merge node was broken when you chose to return a single empty object due to how the paired items were handled.
I stumbled on this while attempting to solve the level 2 course.
Related tickets and issues
Review / Merge checklist
(no-changelog)
otherwise. (conventions)