TEMPLATE_RENDERING_FAILED when wrapping a custom module with a conditional statement

Dear HubSpot team,

I am having trouble sending test email when wrapping a module in a conditional statement:

{% if contact.product_for_email_1__c != 'None' %}
 {% module "module_165944613959018" path="/XXXX/Product card", label="Product card" value={{ contact.product_for_email_1__c }} %}
{% endif %}

On the email live preview, the logic is working fine but when I try to send an test email, I got the following error:

{errorMessage: "Content public api error: portalId: 26081264, path: internal/simple-render/for-html, response: CachingHttpResponse{statusCode=400, body=<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/>\n<title>Error 400 Bad Request</title>\n</head>\n<body><h2>HTTP ERROR 400</h2>\n<p>Reason:\n<pre> Bad Request</pre></p>\n</body>\n</html>\n}" eventId: null ready: true sendResult: null sendStatus: "TEMPLATE_RENDERING_FAILED"}

The content of the custom module is only “Hi”.

If I change the code to

{% if contact.product_for_email_1__c != 'None' %}
 Hi
{% endif %}

The emails preview is fine and I can send test email.

Also, if I try to embedded the logic into the module, the module is always printing Hi, even though module.value = ‘None’. I can send test email though.

{% if module.value != 'None' %}
Hi
{% endif %}

Maybe it’s linked to the fact that contact.product_for_email_1__c is a custom property synced from Salesforce?

Property-settings.png

Could you please advise.

Hi, @ASouy :waving_hand: Thanks for reaching out. Let’s see if we can get the conversation started. @Anton @Jnix284 @assi do you have any experience with the issue @ASouy is describing?

Best,

Jaycee

Dear Jaycee,

As a workaround, I set a variable with the custom property and the conditional statement are working fine :see_no_evil_monkey:

Hey, @ASouy, thank you very much for coming back and adding what worked for you :raising_hands: