Code Node returns Full Item Object on $('node').all()

Describe the problem/error/question

Since n8n v1.0.5 the behaviour of the Code node changed when using $(‘node’).all() function.

In case you want to return the items of a previous node which returned new items without the pairedItem field, the second Code node returns the full item object, including the json and pairedItem fields. See the workflows below.

Is this intended or a bug?

Workflow with the issue:

Output of the “Return Build New Items” Node

[
  {
    "json": {
      "id": "23423536",
      "name": "Edmund Pevensie",
      "email": "[email protected]",
      "notes": "Passionate sailor",
      "country": "UK",
      "created": "1950-10-16"
    },
    "pairedItem": {
      "item": 0
    }
  }
]

Workflow WITHOUT the issue:

Output of the “Return Build New Items” Node

{
  "id": "23423536",
  "name": "Edmund Pevensie",
  "email": "[email protected]",
  "notes": "Passionate sailor",
  "country": "UK",
  "created": "1950-10-16"
}

Information on your n8n setup

  • n8n version: 1.0.5
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: Ubuntu 20.04.6 LTS

Hi @mnebel, welcome to the community!

To be completely honest with you I was not expecting this change either and our migration guide didn’t mention it either. So I too am a bit unsure about whether this is intended or a bug :see_no_evil:

I’ll see if I can get some clarification on this internally and will get back to you once I know more.

3 Likes

Hello @MutedJam,

thank you for your reply!
This also seems to happen by simply using $input.all().

It’s a really strange behaviour.
I hope you can find out the root cause.

Best regards!

So the good news is that the team is able to reliably reproduce this. It’s also very much unexpected. There is no root cause/fix yet, but I’ll provide an update once I hear more.

1 Like

Hi, I’m getting this pairedItem added to my data when I’ve put in a code node to rename files. I’d be inteterested in the outcome too.

The code in the node is simply this:

for (index in items){
items[index].binary.data = Object.assign(items[index].binary.data, {fileName: items[index].json.filename});
}
return items;

The input data is a binary pdf file, plus this json:

{

“cm_c”:“e9495c1e-9993-41ba-bfa9-bd5ddb7ed2cf”,

“cm_l”:“b77b9691-7817-4724-a0cc-3db3b3373c80”,

“filename”:“230602095532 11302 Preliminary Notification.pdf”

}

New version [email protected] got released which includes the GitHub PR 6842.

2 Likes

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