Solved

Null converted into nil

  • 26 April 2023
  • 1 reply
  • 45 views

Hello! 

 

I have created a campaign that triggers based on an event. In this campaign, I consume information from an endpoint, and using the response, I perform an extra request to retrieve the final data. With that final data I componse the email that is sent to our customers.

 

Since a month ago, I’ve noticed that there are errors happening in this process. It looks like when the first response comes, some of the fields can be null, and when I try to map the process seems to fail. My map looks like this:

{{customer.alternatives_based_on_last_listing_visited | map: 'ru_id' | join: ','}}

Even though my API returns null, when Liquid iterates over that attribute (alternatives_based_on_last_listing_visited), it has replaced all the null values with nil, which makes the map fail, and the result of that transformation is the string ru_id, rather than something like 1,2,3,4.

 

Have you faced something similar to this in the past? Any workaround? I cannot modify our API at the moment

icon

Best answer by Ryan_cio 27 April 2023, 11:07

View original

1 reply

Userlevel 1

Hi there,

I tested this out on my end, with your Liquid code and this rendered the array by skipping the null values:

As you can see the null values were skipped, but the map worked and I was able to render the Liquid. I did run into a similar problem that you reported while testing, but I found found that my array wasn’t properly formatted. Could you check that the array is stored correctly as an attribute with no extra characters?

Thanks,

Reply