Why it fails when field is empty? It shouldn't be mandatory

Describe the problem/error/question

I receive a webhook from an external party and I re-send it to a different URL using the HTTP node. Most of the time it works fine when I receive all the “expected” parameters, but occasionally some parameters are not sent because maybe the courier isn’t available yet when I receive the webhook, so it comes as empty… but because I want to send it if it’s there I’m passing it in the HTTP node like this:

How can I make it not mandatory? And just transmit what it’s there… the destination where that information is being sent the fields are not mandatory, so it will take empty value or a value if it’s there…

What is the error message (if any)?

ERROR: Cannot read properties of undefined (reading ‘name’)

I know I can work around it by “constructing” the json with javascript including only the non-empty values and transmitting that result into the HTTP request using JSON body instead of fields… just curious to see if there’s any other way

Hi @yukyo, I am very sorry you are having trouble. Can you share the exact workflow you are using and also an example of the JSON data your Webhook node passes on (you can redact anything confidential of course, as long as the problem remains reproducible)?

Also, can you confirm the exact n8n version you have in use? The expressions from your screenshot suggest you might be using an older version of n8n.

A simple workaround you could try (without knowing your exact setup) would be the use of optional chaining, which would simply return undefined instead of throwing an error.