I created a long zap with various steps. Some of them include some Javascript “Code by Zapier” steps.
The inputData is the result of a Snowflake SQL query, so sometimes it returned 0 result.
Because of that, as I was iterating the results, it was throwing the dreaded “TypeError: Cannot read property 'trim' of undefined”.
I wanted to fix that by creating a logic to check the data and stop the script. See below:
// Catch empty data and return empty value
if (
!inputData ||
!inputData.dates ||
!inputData.integrations ||
!inputData.counts
) {
console.error(
"Missing or empty inputData properties. Cannot create the chart."
);
output = { url: "Not enough data" };
return output;
}
(note that I need to return something or the step fails)
Now the strangest thing happened:
- The test of the zap shows no issue if there’s correct inputData or not
- In production, when testing the complete zap, there’s still the “TypeError: Cannot read property 'trim' of undefined” with correct data
- As a consequence, the last steps are skipped, and I can’t find a way to avoid that
I made sure:
- the history showed the last version of my code
- the variable names are correct
- the inputData was correct
I also contacted Support who were not able to help (so far).
We’re a paying customer for a long time, and I don’t know what to do to fix it.