HTTP Request hard to debug with multiple items/error handling

Use case :
I have a list of URL that I need to request, so I have a node that loads the list, then it queries all url.

Problem :
If any query fails, the whole workflow fails and the error only display the result of the query that failed. There is no infos about the query itself so it is impossible to figure out which url causes the error.

It would be great to add more details in the error (perhaps in some sort of callstack ?) with elements from the query itself.
Also, it may be ok in some cases to “ignore” errors (some items of the list may not be available during the process), would it be possible to add some kind of “ignore errors” option, or even better, a “on error” output ?

@airmoi

Yeah, I see how that can be handy. I encountered this “issue” one time. In my mind, this has to be handled in the core instead of handling that on each node.

I think you can solve the “if any query fails, the whole workflow fails” by using the splitInbatches node.

If I understood well you have something like this. In that example the second request needs the be made but cuz the first one failed the second one which should be successful never is executed.

{
      "nodes": [
        {
          "parameters": {},
          "name": "Start",
          "type": "n8n-nodes-base.start",
          "typeVersion": 1,
          "position": [
            250,
            300
          ]
        },
        {
          "parameters": {
            "functionCode": "return [\n  {\n    json: {\n      url: 'https://dog.ceo/api/breeds/image/random2',\n    }\n  },\n    {\n    json: {\n      url: 'https://dog.ceo/api/breeds/image/random',\n    }\n  },\n]"
          },
          "name": "Function",
          "type": "n8n-nodes-base.function",
          "typeVersion": 1,
          "position": [
            480,
            300
          ]
        },
        {
          "parameters": {
            "url": "={{$node[\"Function\"].data[\"url\"]}}",
            "options": {}
          },
          "name": "HTTP Request",
          "type": "n8n-nodes-base.httpRequest",
          "typeVersion": 1,
          "position": [
            710,
            300
          ]
        }
      ],
      "connections": {
        "Start": {
          "main": [
            [
              {
                "node": "Function",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Function": {
          "main": [
            [
              {
                "node": "HTTP Request",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    }

In this second example using splitInBatches at least the request who failed does not stop the workflow. It’s just “ignored”. Make sure you have the “continue on fail” set to true on the http node.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      url: 'https://dog.ceo/api/breeds/image/random2',\n    }\n  },\n    {\n    json: {\n      url: 'https://dog.ceo/api/breeds/image/random',\n    }\n  },\n]"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        480,
        300
      ]
    },
    {
      "parameters": {
        "url": "={{$node[\"SplitInBatches\"].data[\"url\"]}}",
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        910,
        300
      ],
      "continueOnFail": true
    },
    {
      "parameters": {
        "batchSize": 1
      },
      "name": "SplitInBatches",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 1,
      "position": [
        690,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{$node[\"SplitInBatches\"].context[\"noItemsLeft\"]}}",
              "value2": true
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1110,
        100
      ]
    },
    {
      "parameters": {},
      "name": "NoOp",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1340,
        80
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SplitInBatches": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "NoOp",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Great I’ll try this.

Thanks for the tip

Ah yes, that is all correct. A similar problem came up with the NextCloud node:

So with the new version of [email protected] it is now possible to do that on a node level. For now, I just updated the NextCloud and the HTTP Request-Node. If “Continue On Fail” gets set for them, it adds an item with the property “error” and then goes on to the next one. So you can for now filter them out like this.

We have to however look for a proper long-term solution

2 Likes

Working as expected !
Took me a minute to figure out where the option was (node tab), but its ok.

Perhaps the tooltip should be updated because it does not mention that there will be an error property in case of failure

Great that it works now!

Ah yes I did not update the message on purpose for two reasons:

  1. Currently it does only do it for the two above mentioned nodes
  2. Like mentioned do we have to look for a proper long-term solution and I am not sure that this is it