fix(editor): Disallow drag-and-drop for non-immediate-ancestors of Python code node (#20773)

This commit is contained in:
Iván Ovejero 2025-10-15 09:45:03 +02:00 committed by GitHub
parent 86af6e95c2
commit 0fab5ea3d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 0 deletions

View File

@ -123,6 +123,36 @@ const y = f({ a: 'c' })
valueToInsert('{{ $json.foo.bar[0].baz }}', 'pythonNative', 'runOnceForEachItem'),
).toBe('{{ _item["json"]["foo"]["bar"][0]["baz"] }}');
});
it('should return empty string for specific node references (single quotes), runOnceForAllItems', () => {
expect(
valueToInsert(
"{{ $('Some Previous Node').item.json.foo.bar[0].baz }}",
'pythonNative',
'runOnceForAllItems',
),
).toBe('');
});
it('should return empty string for specific node references (double quotes), runOnceForAllItems', () => {
expect(
valueToInsert(
'{{ $("Some Previous Node").item.json.foo.bar[0].baz }}',
'pythonNative',
'runOnceForAllItems',
),
).toBe('');
});
it('should return empty string for specific node references, runOnceForEachItem', () => {
expect(
valueToInsert(
"{{ $('Some Previous Node').item.json.foo.bar[0].baz }}",
'pythonNative',
'runOnceForEachItem',
),
).toBe('');
});
});
});
});

View File

@ -67,6 +67,9 @@ const toBracketNotation = (input: string): string => {
};
const pythonInsert = (value: string, mode: CodeExecutionMode): string => {
// Python supports only direct parent node references
if (value.includes('$(')) return '';
const base =
mode === 'runOnceForAllItems'
? value.replace('$json', '_items[0]["json"]')