fix(core): Allow index as top-level item key for Code node (#12469)

This commit is contained in:
Iván Ovejero
2025-01-06 15:03:36 +01:00
committed by GitHub
parent 3109de6073
commit 1b9100032f
4 changed files with 34 additions and 2 deletions

View File

@@ -28,6 +28,7 @@ describe('result validation', () => {
['binary', {}],
['pairedItem', {}],
['error', {}],
['index', {}], // temporarily allowed until refactored out
])(
'should not throw an error if the output item has %s key in addition to json',
(key, value) => {

View File

@@ -4,7 +4,19 @@ import type { INodeExecutionData } from 'n8n-workflow';
import { ValidationError } from './errors/validation-error';
import { isObject } from './obj-utils';
export const REQUIRED_N8N_ITEM_KEYS = new Set(['json', 'binary', 'pairedItem', 'error']);
export const REQUIRED_N8N_ITEM_KEYS = new Set([
'json',
'binary',
'pairedItem',
'error',
/**
* The `index` key was added accidentally to Function, FunctionItem, Gong,
* Execute Workflow, and ToolWorkflowV2, so we need to allow it temporarily.
* Once we stop using it in all nodes, we can stop allowing the `index` key.
*/
'index',
]);
function validateTopLevelKeys(item: INodeExecutionData, itemIndex: number) {
for (const key in item) {