Repository navigation
Conversation
There was a problem hiding this comment.
No issues found across 4 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would not auto-approve. Auto-approval skipped because this PR is from an external contributor.
View guided diff | Re-trigger cubic
|
Hey @kevin9327, Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request. Before we can proceed, please ensure the following: • Your PR references the GitHub issue it fixes (or, for feature requests, a link to the corresponding community forum post). • Tests are included for any new functionality, logic changes or bug fixes. • The PR aligns with our contribution guidelines. Why the linked issue matters: Our teams pick up work from the issue, not from individual pull requests — the issue is what reaches them, with your PR linked to it. So please make sure the issue contains everything needed to judge the change: a clear problem description, reproduction steps, and the expected behaviour. If the issue is thin, add the missing context there rather than only in the PR description. Regarding new nodes: We no longer accept new nodes directly into the core codebase. Instead, we encourage contributors to follow our Community Node Submission Guide to publish nodes independently. If your node integrates with an AI service that you own or represent, please email [email protected] and we will be happy to discuss the best approach. About review timelines: While we plan to review it as soon as possible, we are currently unable to provide an exact timeframe. Our goal is to begin reviews within a month, but this may change depending on team priorities. We will reach out when the review begins. Please also note that other contributors may have opened pull requests for the same issue. We keep them all open so the reviewing team can choose the approach that fits best. Once the issue is resolved, the remaining pull requests are closed — this is not a judgement on the quality of your work, and we're grateful for it either way. Thank you again for contributing to n8n. |
1 similar comment
|
Hey @kevin9327, Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request. Before we can proceed, please ensure the following: • Your PR references the GitHub issue it fixes (or, for feature requests, a link to the corresponding community forum post). • Tests are included for any new functionality, logic changes or bug fixes. • The PR aligns with our contribution guidelines. Why the linked issue matters: Our teams pick up work from the issue, not from individual pull requests — the issue is what reaches them, with your PR linked to it. So please make sure the issue contains everything needed to judge the change: a clear problem description, reproduction steps, and the expected behaviour. If the issue is thin, add the missing context there rather than only in the PR description. Regarding new nodes: We no longer accept new nodes directly into the core codebase. Instead, we encourage contributors to follow our Community Node Submission Guide to publish nodes independently. If your node integrates with an AI service that you own or represent, please email [email protected] and we will be happy to discuss the best approach. About review timelines: While we plan to review it as soon as possible, we are currently unable to provide an exact timeframe. Our goal is to begin reviews within a month, but this may change depending on team priorities. We will reach out when the review begins. Please also note that other contributors may have opened pull requests for the same issue. We keep them all open so the reviewing team can choose the approach that fits best. Once the issue is resolved, the remaining pull requests are closed — this is not a judgement on the quality of your work, and we're grateful for it either way. Thank you again for contributing to n8n. |
ManyaS-Git
left a comment
There was a problem hiding this comment.
Hey @kevin9327, nice catch and great explanation of the bug in #41485! Looping over extraArgs so output values align with the requested field order makes total sense and prevents unexpected tuple misalignment across items with different key insertion orders.
A few observations and suggestions from reviewing the diff:
1. Avoiding new Set(Object.keys(current)) allocations on every item
Inside value.reduce, calling const keys = new Set(Object.keys(current)) allocates a new string array and a Set instance for each item in value:
const keys = new Set(Object.keys(current));
(extraArgs as string[]).forEach((field) => {
if (keys.has(field)) {
p.push((current as { [key: string]: unknown })[field]);
}
});When plucking large datasets (e.g. workflows with thousands of items), this creates unnecessary memory churn and GC pressure. Using Object.prototype.hasOwnProperty.call(current, field) (or Object.hasOwn(current, field)) checks whether field is an own property in O(1) time without any per-item allocations.
2. Handling numeric property keys
Set.has() uses strict equality (SameValueZero), whereas property access coerces keys to strings. If a workflow calls .pluck(0, 1) or accesses numeric keys on tuple-like items, Object.keys(current) produces string keys (['0', '1']), so keys.has(0) evaluates to false. In contrast, Object.prototype.hasOwnProperty.call(current, field) coerces the argument, preserving numeric key support.
3. Test consistency with expression evaluation
In packages/workflow/test/ExpressionExtensions/array-extensions.test.ts, the neighboring tests use the evaluate("={{ [...] }}") helper to verify end-to-end expression parsing and execution together. How about using evaluate() for the new test case as well to keep test conventions consistent with the rest of the suite?
WDYT? 🙂
|
Thanks for the review, @ManyaS-Git.
|
Summary
Array.pluck()with more than one field now returns each item's values in the order of the field names passed in. Before this change it used the order of each object's own keys. The fix is applied to both copies of the extension:n8n-workflowand its mirror in@n8n/expression-runtime.Why
plucklooped overObject.keys(item)first and over the requested fields second. When items had their keys in different orders, the inner arrays didn't line up:[{ lastName: 'Doe', firstName: 'John' }, { firstName: 'Jane', lastName: 'Roe' }].pluck('firstName', 'lastName')returned[["Doe","John"],["Jane","Roe"]]. Now the code loops over the requested fields and only checks that each one is an own enumerable key, so which fields get included doesn't change.How to test
Evaluate
{{ [{ lastName: 'Doe', firstName: 'John' }, { firstName: 'Jane', lastName: 'Roe' }].pluck('firstName', 'lastName') }}in an expression. The result is now[["John","Doe"],["Jane","Roe"]].I added unit tests to both packages'
array-extensionstest files. I ran the@n8n/expression-runtimefile with vitest: the new test fails before the fix, and all 15 tests pass after it. Forn8n-workflowI didn't do a full install, so I checked the same assertion againstarrayExtensions.functions.pluckin a scratch setup instead: it fails before the fix and passes after.Related Linear tickets, Github issues, and Community forum posts
Fixes #41485
Review / Merge checklist
Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)AI assistance: Grok Bot (AI assistant) helped find this bug and write the fix and tests. I reviewed and ran them.