Error when debugging splitinbatches node

Describe the issue/error/question

When I try to execute the SplitInBatches node in order to debug, I am getting this error, when executing the entire workflow, no error occurs.

What is the error message (if any)?

Problem executing workflow
There was a problem executing the workflow:
"Cannot read property ‘0’ of undefined"

Please share the workflow

Information on your n8n setup

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

Hi @Martin_Neumann, I am sorry to hear you’re having trouble here.

Could you share the JSON data coming from your WooCommerce node so I can give this a go on m end? You can of course redact the data, I’m just interested in the structure, not the actual values.

I am giving you the first 2 and the last from 25 records:

[{
        "id": 4627,
        "parent_id": 0,
        "status": "completed",
        "currency": "BRL",
        "version": "6.5.1",
        "prices_include_tax": false,
        "date_created": "2022-05-05T13:57:31",
        "date_modified": "2022-05-31T11:27:33",
        "discount_total": "0.00",
        "discount_tax": "0.00",
        "shipping_total": "0.00",
        "shipping_tax": "0.00",
        "cart_tax": "0.00",
        "total": "97.00",
        "total_tax": "0.00",
        "customer_id": 398,
        "order_key": "wc_order_PWSEpaAZNljfZ",
        "billing": {
            "first_name": "Fla",
            "last_name": "xx",
            "company": "",
            "address_1": "",
            "address_2": "",
            "city": "",
            "state": "",
            "postcode": "",
            "country": "",
            "email": "[email protected]",
            "phone": "",
            "number": "",
            "neighborhood": "",
            "persontype": "F",
            "cpf": "",
            "rg": "",
            "cnpj": "",
            "ie": "",
            "birthdate": "",
            "sex": "",
            "cellphone": "00"
        },
        "shipping": {
            "first_name": "",
            "last_name": "",
            "company": "",
            "address_1": "",
            "address_2": "",
            "city": "",
            "state": "",
            "postcode": "",
            "country": "",
            "phone": "",
            "number": "",
            "neighborhood": ""
        },
        "payment_method": "bacs",
        "payment_method_title": "Transferência bancária ou PIX",
        "transaction_id": "",
        "customer_ip_address": "xx",
        "customer_user_agent": "Mozilla/5.0 (Linux; Android 10; LM-K510) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Mobile Safari/537.36",
        "created_via": "checkout",
        "customer_note": "",
        "date_completed": "2022-05-31T11:27:33",
        "date_paid": "2022-05-31T11:27:33",
        "cart_hash": "28a30b0b64e23cbcb56f048975237a88",
        "number": "4627",
        "meta_data": [{
                "id": 41588,
                "key": "_billing_cellphone",
                "value": "00"
            },
            {
                "id": 41589,
                "key": "is_vat_exempt",
                "value": "no"
            },
            {
                "id": 41590,
                "key": "cl_wc_session_id",
                "value": "8669ec59d8f7998b7827ec11c437297a"
            },
            {
                "id": 41591,
                "key": "_wpfunnels_checkout_id",
                "value": "4370"
            },
            {
                "id": 41592,
                "key": "_wpfunnels_funnel_id",
                "value": "4367"
            },
            {
                "id": 41593,
                "key": "_wpfunnels_order_unique_identifier",
                "value": "627401bc84f86"
            },
            {
                "id": 41594,
                "key": "order_comments",
                "value": ""
            },
            {
                "id": 41598,
                "key": "_new_order_email_sent",
                "value": "true"
            },
            {
                "id": 43077,
                "key": "_billing_persontype",
                "value": "0"
            },
            {
                "id": 43078,
                "key": "_billing_cpf",
                "value": ""
            },
            {
                "id": 43079,
                "key": "_billing_cnpj",
                "value": ""
            },
            {
                "id": 43080,
                "key": "_billing_number",
                "value": ""
            },
            {
                "id": 43081,
                "key": "_billing_neighborhood",
                "value": ""
            },
            {
                "id": 43082,
                "key": "_shipping_number",
                "value": ""
            },
            {
                "id": 43083,
                "key": "_shipping_neighborhood",
                "value": ""
            }
        ],
        "line_items": [{
            "id": 246,
            "name": "Pães, Massas, Salgados e Bolos sem Gluten",
            "product_id": 4309,
            "variation_id": 0,
            "quantity": 1,
            "tax_class": "",
            "subtotal": "97.00",
            "subtotal_tax": "0.00",
            "total": "97.00",
            "total_tax": "0.00",
            "taxes": [],
            "meta_data": [],
            "sku": "",
            "price": 97,
            "parent_name": null
        }],
        "tax_lines": [],
        "shipping_lines": [],
        "fee_lines": [],
        "coupon_lines": [],
        "refunds": [],
        "payment_url": "https://www.saudeplena.org/finalizar-compra/pedido-pagar/4627/?pay_for_order=true&key=wc_order_PWSEpaAZNljfZ",
        "date_created_gmt": "2022-05-05T16:57:31",
        "date_modified_gmt": "2022-05-31T14:27:33",
        "date_completed_gmt": "2022-05-31T14:27:33",
        "date_paid_gmt": "2022-05-31T14:27:33",
        "correios_tracking_code": "",
        "currency_symbol": "R$",
        "_links": {
            "self": [{
                "href": "https://www.saudeplena.org/wp-json/wc/v3/orders/4627"
            }],
            "collection": [{
                "href": "https://www.saudeplena.org/wp-json/wc/v3/orders"
            }],
            "customer": [{
                "href": "https://www.saudeplena.org/wp-json/wc/v3/customers/398"
            }]
        }
    },
    {
        "id": 4624,
        "parent_id": 0,
        "status": "completed",
        "currency": "BRL",
        "version": "6.5.1",
        "prices_include_tax": false,
        "date_created": "2022-05-03T16:19:23",
        "date_modified": "2022-05-03T16:38:45",
        "discount_total": "0.00",
        "discount_tax": "0.00",
        "shipping_total": "0.00",
        "shipping_tax": "0.00",
        "cart_tax": "0.00",
        "total": "97.00",
        "total_tax": "0.00",
        "customer_id": 392,
        "order_key": "wc_order_DIaplHXQ5fE8j",
        "billing": {
            "first_name": "xx",
            "last_name": "xt",
            "company": "",
            "address_1": "",
            "address_2": "",
            "city": "",
            "state": "",
            "postcode": "",
            "country": "",
            "email": "[email protected]",
            "phone": "",
            "number": "",
            "neighborhood": "",
            "persontype": "F",
            "cpf": "",
            "rg": "",
            "cnpj": "",
            "ie": "",
            "birthdate": "",
            "sex": "",
            "cellphone": "000"
        },
        "shipping": {
            "first_name": "",
            "last_name": "",
            "company": "",
            "address_1": "",
            "address_2": "",
            "city": "",
            "state": "",
            "postcode": "",
            "country": "",
            "phone": "",
            "number": "",
            "neighborhood": ""
        },
        "payment_method": "pagseguro",
        "payment_method_title": "PagSeguro (Cartão)",
        "transaction_id": "xxx",
        "customer_ip_address": "xxx",
        "customer_user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1",
        "created_via": "checkout",
        "customer_note": "",
        "date_completed": "2022-05-03T16:38:45",
        "date_paid": "2022-05-03T16:23:03",
        "cart_hash": "f4e9d34650f6402f3ed1134263cc84dc",
        "number": "4624",
        "meta_data": [{
                "id": 41465,
                "key": "_billing_cellphone",
                "value": "000"
            },
            {
                "id": 41466,
                "key": "is_vat_exempt",
                "value": "no"
            },
            {
                "id": 41467,
                "key": "cl_wc_session_id",
                "value": "233ca4f33570306434eda523a0de5400"
            },
            {
                "id": 41468,
                "key": "_wpfunnels_checkout_id",
                "value": "4370"
            },
            {
                "id": 41469,
                "key": "_wpfunnels_funnel_id",
                "value": "4367"
            },
            {
                "id": 41470,
                "key": "_wpfunnels_order_unique_identifier",
                "value": "62717fac7f5aa"
            },
            {
                "id": 41471,
                "key": "order_comments",
                "value": ""
            },
            {
                "id": 41472,
                "key": "E-mail do comprador",
                "value": "[email protected]"
            },
            {
                "id": 41473,
                "key": "Nome do comprador",
                "value": "xtx"
            },
            {
                "id": 41474,
                "key": "Tipo de pagamento",
                "value": "Cartão de Crédito"
            },
            {
                "id": 41475,
                "key": "Método de pagamento",
                "value": "Cartão de crédito Visa"
            },
            {
                "id": 41476,
                "key": "Parcelas",
                "value": "1"
            },
            {
                "id": 41477,
                "key": "_wc_pagseguro_payment_data",
                "value": {
                    "type": 1,
                    "method": "Cartão de crédito Visa",
                    "installments": "1",
                    "link": ""
                }
            },
            {
                "id": 41485,
                "key": "_new_order_email_sent",
                "value": "true"
            }
        ],
        "line_items": [{
            "id": 244,
            "name": "Pães, Massas, Salgados e Bolos sem Gluten",
            "product_id": 4309,
            "variation_id": 0,
            "quantity": 1,
            "tax_class": "",
            "subtotal": "97.00",
            "subtotal_tax": "0.00",
            "total": "97.00",
            "total_tax": "0.00",
            "taxes": [],
            "meta_data": [],
            "sku": "",
            "price": 97,
            "parent_name": null
        }],
        "tax_lines": [],
        "shipping_lines": [],
        "fee_lines": [],
        "coupon_lines": [],
        "refunds": [],
        "payment_url": "https://www.saudeplena.org/finalizar-compra/pedido-pagar/4624/?pay_for_order=true&key=wc_order_DIaplHXQ5fE8j",
        "date_created_gmt": "2022-05-03T19:19:23",
        "date_modified_gmt": "2022-05-03T19:38:45",
        "date_completed_gmt": "2022-05-03T19:38:45",
        "date_paid_gmt": "2022-05-03T19:23:03",
        "correios_tracking_code": "",
        "currency_symbol": "R$",
        "_links": {
            "self": [{
                "href": "https://www.saudeplena.org/wp-json/wc/v3/orders/4624"
            }],
            "collection": [{
                "href": "https://www.saudeplena.org/wp-json/wc/v3/orders"
            }],
            "customer": [{
                "href": "https://www.saudeplena.org/wp-json/wc/v3/customers/392"
            }]
        }
    },
    {
        "id": 4334,
        "parent_id": 0,
        "status": "completed",
        "currency": "BRL",
        "version": "6.3.1",
        "prices_include_tax": false,
        "date_created": "2022-03-22T16:21:58",
        "date_modified": "2022-03-23T09:30:19",
        "discount_total": "0.00",
        "discount_tax": "0.00",
        "shipping_total": "0.00",
        "shipping_tax": "0.00",
        "cart_tax": "0.00",
        "total": "97.00",
        "total_tax": "0.00",
        "customer_id": 361,
        "order_key": "wc_order_3Y7ehjZl7P9Aw",
        "billing": {
            "first_name": "xxx",
            "last_name": "xxx",
            "company": "",
            "address_1": "xxx",
            "address_2": "",
            "city": "xxx",
            "state": "RS",
            "postcode": "xxx",
            "country": "BR",
            "email": "[email protected]",
            "phone": "xxx",
            "number": "132",
            "neighborhood": "xxx",
            "persontype": "F",
            "cpf": "xxx",
            "rg": "",
            "cnpj": "",
            "ie": "",
            "birthdate": "",
            "sex": "",
            "cellphone": "(000"
        },
        "shipping": {
            "first_name": "",
            "last_name": "",
            "company": "",
            "address_1": "",
            "address_2": "",
            "city": "",
            "state": "",
            "postcode": "",
            "country": "",
            "phone": "",
            "number": "",
            "neighborhood": ""
        },
        "payment_method": "pagseguro",
        "payment_method_title": "PagSeguro (Cartão)",
        "transaction_id": "xxx",
        "customer_ip_address": "xxx",
        "customer_user_agent": "Mozilla/5.0 (Linux; Android 11; moto g(20)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.73 Mobile Safari/537.36",
        "created_via": "checkout",
        "customer_note": "",
        "date_completed": "2022-03-23T09:30:19",
        "date_paid": "2022-03-22T16:25:12",
        "cart_hash": "f3add92c85ea7c74eb73e086953120b7",
        "number": "4334",
        "meta_data": [{
                "id": 37565,
                "key": "_billing_persontype",
                "value": "1"
            },
            {
                "id": 37566,
                "key": "_billing_cpf",
                "value": "xxx"
            },
            {
                "id": 37567,
                "key": "_billing_cnpj",
                "value": ""
            },
            {
                "id": 37568,
                "key": "_billing_number",
                "value": "132"
            },
            {
                "id": 37569,
                "key": "_billing_neighborhood",
                "value": "xxx"
            },
            {
                "id": 37570,
                "key": "_billing_cellphone",
                "value": "000"
            },
            {
                "id": 37571,
                "key": "is_vat_exempt",
                "value": "no"
            },
            {
                "id": 37572,
                "key": "_wc_facebook_for_woocommerce_order_placed",
                "value": "yes"
            },
            {
                "id": 37573,
                "key": "E-mail do comprador",
                "value": "[email protected]"
            },
            {
                "id": 37574,
                "key": "Nome do comprador",
                "value": "Cristiane da Silva Leite"
            },
            {
                "id": 37575,
                "key": "Tipo de pagamento",
                "value": "Cartão de Crédito"
            },
            {
                "id": 37576,
                "key": "Método de pagamento",
                "value": "Cartão de crédito MasterCard"
            },
            {
                "id": 37577,
                "key": "Parcelas",
                "value": "2"
            },
            {
                "id": 37578,
                "key": "_wc_pagseguro_payment_data",
                "value": {
                    "type": 1,
                    "method": "Cartão de crédito MasterCard",
                    "installments": "2",
                    "link": ""
                }
            },
            {
                "id": 37586,
                "key": "_new_order_email_sent",
                "value": "true"
            }
        ],
        "line_items": [{
            "id": 196,
            "name": "Pães, Massas, Salgados e Bolos sem Gluten",
            "product_id": 4309,
            "variation_id": 0,
            "quantity": 1,
            "tax_class": "",
            "subtotal": "97.00",
            "subtotal_tax": "0.00",
            "total": "97.00",
            "total_tax": "0.00",
            "taxes": [],
            "meta_data": [],
            "sku": "",
            "price": 97,
            "parent_name": null
        }],
        "tax_lines": [],
        "shipping_lines": [],
        "fee_lines": [],
        "coupon_lines": [],
        "refunds": [],
        "payment_url": "https://www.saudeplena.org/finalizar-compra/pedido-pagar/4334/?pay_for_order=true&key=wc_order_3Y7ehjZl7P9Aw",
        "date_created_gmt": "2022-03-22T19:21:58",
        "date_modified_gmt": "2022-03-23T12:30:19",
        "date_completed_gmt": "2022-03-23T12:30:19",
        "date_paid_gmt": "2022-03-22T19:25:12",
        "correios_tracking_code": "",
        "currency_symbol": "R$",
        "_links": {
            "self": [{
                "href": "https://www.saudeplena.org/wp-json/wc/v3/orders/4334"
            }],
            "collection": [{
                "href": "https://www.saudeplena.org/wp-json/wc/v3/orders"
            }],
            "customer": [{
                "href": "https://www.saudeplena.org/wp-json/wc/v3/customers/361"
            }]
        }
    }
]

Thanks @Martin_Neumann. This seems to work fine for me when testing this on my own instance using a slightly modified workflow:

All three items are being sent to the webhook URL as expected:

Can you confirm whether the problem also occurs to you using only the data you have provided?

I tried to import the workflow, but it gives me the following error when running:

Problem executing workflow

There was a problem executing the workflow:
"Mock Data: All returned items have to contain a property named “json”! [Line 104]"

Not sure why!

But actually, on my original workflow it is running fine if I start the entire workflow. If I execute every node separately for debugging purposes, I am getting the above error once I try to execute the SplintInBatches node. I actually have problems to debug SplitInBatches in other workflows as well, it is making it difficult for me to debug or construct anything.

There was a problem executing the workflow: “Mock Data: All returned items have to contain a property named “json”! [Line 104]”
Not sure why!

Sorry for that, I wrote the Mock code using the current n8n version. n8n version before 0.166.0 still require a json key for each object in the array returned by the Function node, I should have kept that in mind seeing you are using [email protected].

But actually, on my original workflow it is running fine if I start the entire workflow. If I execute every node separately for debugging purposes, I am getting the above error once I try to execute the SplintInBatches node.

This additional piece of information is super helpful and I could reproduce the problem. I’ll add this to our internal bug tracker for a closer look.