-
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(core): Fix validation of items returned in the task runner (no-changelog) #11897
fix(core): Fix validation of items returned in the task runner (no-changelog) #11897
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
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.
Thanks for the fix! 🙏🏻
Let's merge this, but I have some more general questions about item validation.
@@ -9,7 +9,7 @@ export const REQUIRED_N8N_ITEM_KEYS = new Set(['json', 'binary', 'pairedItem', ' | |||
function validateTopLevelKeys(item: INodeExecutionData, itemIndex: number) { | |||
for (const key in item) { | |||
if (Object.prototype.hasOwnProperty.call(item, key)) { | |||
if (REQUIRED_N8N_ITEM_KEYS.has(key)) return; | |||
if (REQUIRED_N8N_ITEM_KEYS.has(key)) continue; |
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.
Lucky we caught this early!
- I notice that there is some duplication between
./packages/@n8n/task-runner/src/js-task-runner/result-validation.ts
and./packages/@n8n/task-runner/src/js-task-runner/result-validation.ts
. The versions risk drifting apart as validation is updated in the Code node. Should this validation exist only once inn8n-core
and be imported into the runner and into the Code node sandbox? - I also notice the runner and the Code node sandbox do not share all validation, e.g.
Access the properties of an item under .json, e.g. item.json
andIn the returned data, every key named 'json' must point to an object.
are duplicated, butPlease return an array of objects, one for each item you would like to output
andPlease return an object representing the output item. ('${executionResult}' was returned instead.)
exist only in the Code node sandbox. Is this an issue also?
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.
💯! Very good questions!
- I assume you mean between task runner and the Code Node Sandbox? The Sandbox should eventually go away entirely, so that duplication will be solved by that.
- I couldn't find any mismatches between the two. E.g. the
Please return an array of objects
is in Sandbox and also in the runner. Maybe you missed it because the code doesn't match 1:1 (the Sandbox uses some interpolation)
n8n Run #8107
Run Properties:
|
Project |
n8n
|
Branch Review |
master
|
Run status |
Passed #8107
|
Run duration | 04m 40s |
Commit |
a535e88f1a: 🌳 master 🖥️ browsers:node18.12.0-chrome107 🤖 PR User 🗃️ e2e/*
|
Committer | Tomi Turtiainen |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
1
|
Pending |
0
|
Skipped |
0
|
Passing |
478
|
View all changes introduced in this branch ↗︎ |
✅ All Cypress E2E specs passed |
Got released with |
Summary
Fix validation and add tests
Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/CAT-363/adding-a-property-to-the-item-top-level-does-not-throw
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)