[Bug] [Breaking]

Hi @jan, not sure if I should have posted this here or in github, but here it goes…

Some recent update on n8n broke a couple of workflows on my side.

Here’s an example that reproduces the behaviour:

I expected https://webhook.site/#!/1881182c-ff05-4ae8-ab1f-a210d94dae2b/f9791288-f264-4b9e-97a7-a1192fa95a03/1 to have two requests with the following query parameters:

  • 1st request: value=test1
  • 2nd request: value=test2

But both requests have value=test2

This used to work on previous versions and somehow stopped working. I can see this not working on several other nodes, postgres, airtable and others.

Let me know what other info I should provide to help u debug this.

{
  "name": "n8n-bug-example",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "value",
              "value": "test1"
            }
          ]
        },
        "options": {}
      },
      "name": "Set-Value1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        600,
        240
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "value",
              "value": "test2"
            }
          ]
        },
        "options": {}
      },
      "name": "Set-Value2",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        600,
        390
      ]
    },
    {
      "parameters": {
        "url": "https://webhook.site/1881182c-ff05-4ae8-ab1f-a210d94dae2b",
        "jsonParameters": true,
        "options": {},
        "queryParametersJson": "={ \"value\": \"{{$node[\"Collector\"].json[\"value\"]}}\" }"
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1110,
        310
      ]
    },
    {
      "parameters": {},
      "name": "Collector",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        870,
        310
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Set-Value1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Set-Value2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set-Value1": {
      "main": [
        [
          {
            "node": "Collector",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set-Value2": {
      "main": [
        [
          {
            "node": "Collector",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collector": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": "94"
}

Ah wow yes, for this case there was then probably breaking change a while ago. In the past expressions choose by default the data of the same run-index. This caused however incredible many problems for many users as they wrote expressions on nodes that got executed 2+ times and referenced data on other nodes which got executed only 1 time (which did then fail). So it got changed that expressions use by default always the data of the last execution as I never came across a case where it was needed differently and the other behavior needed always a lot of strange workarounds. Your case I thought would also still work on the first sight with the new behavior, but it probably breakes because of the order the nodes get added to the stack. As the collector gets added 2x in a row before at least 1x the HTTP Request nodes, this breaks. I am very sorry for that!

To make that work again there are two possibilities. Use on the HTTP Request Node instead of this {{$node["Collector"].json["value"]}} one of the following expressions:

  1. {{$json["value"]}} - That will simply use the incoming data the node receives
  2. {{$items("Collector", 0, $runIndex)[0].json["value"]}} - This says specifically to get the data of the same run-index the current node is on

I see. Yeah it makes sense. I don’t see $json in the documentation. I’m assuming this is new (?). Can u point me to its documentation please?

Tested with $json and it works as expected! Thanks @jan

Edit: Also is there a place we can see the changelog or the release notes?

Yes you are correct $json is not officially documented yet even though it already exists for a while now. I remember that there were some possible issues in some edge-cases and for that reason did I not create documentation yet before I had some time to check it properly.

There is no changelog yet. You would have to look through the Github-logs for now. They clearly state when what version got released. We have planned to add proper changelog soon.

All known breaking changes get documented here:

1 Like