Code node gives ERROR


Describe the issue/error/question

Code node gives ERROR with a large number of elements

With a small number of elements, everything works:

What is the error message

If there are more elements, it no longer works:

Please share the workflow

Share the output returned by the last node

ERROR: Cannot read properties of undefined (reading ‘split’) [line 5]

TypeError: Cannot read properties of undefined (reading 'split')
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:5:10
    at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/bridge.js:485:11)
    at (<anonymous>)
    at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/bridge.js:485:11)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:2:4
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:9:2
    at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/bridge.js:485:11)
    at (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/nodevm.js:426:23)
    at Sandbox.runCodeAllItems (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/Sandbox.js:53:42)
    at Sandbox.runCode (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/Sandbox.js:30:62)

Information on your n8n setup

  • n8n version: 0.213.0
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm,, desktop app]: Docker

Hey @Mikhail,

Can you do a check to make sure all of your items includes the ImageUrls property, It could just be that it doesn’t exist.

I am able to produce the same error if I just delete that key from one of the mostly empty rows.

1 Like

Hey @Jon !
Thank you for the response!

A few tests:
One element (without the "| " sign)

Empty element:

Yes, this is where the error comes out:

Could you please guide me on how to edit the code node?

  e => e.json.Images = {
    Image: e.json.ImageUrls
      ?.split(" | ")
      .map( i => ({ url: i }) )

return $input.all();

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.