N
Novu6mo ago
Etigma

Shadow Payload

Hello ! I'm trying to use Novu with the java sdk and as self-hosted. Actually it work pretty well. I use a payload in this form: Map(String, List<String>) I've tried somes key, value, like: NEWS : [ "new_one" ] IMPORTANT_NEWS : [ "new_two" ] And i try to send email with this informations. To know if there is any News or Important News, i use {{#if NEWS}} in the email template. But for somes times now, even if i don't send IMPORTANT_NEWS in my payload (I just send NEWS, or nothing) IMPORTANT_NEWS will be found in the notification payload, as true (and not as empty list/null/other) Did someone encountered the same problem ?
5 Replies
Ask Inkeep
Ask Inkeep6mo ago
Hi @Etigma, I'm an AI assistant for Novu. While a team member reviews this question, I'll see if I can find relevant sources for your question. ----------------------------- While I generate an answer, here are some sources that might be helpful: * Java SDK * Java quickstart * How to send notifications with Next.js and MJML * How to send notifications with Next.js and React email ----------------------------- Answer Thank you for your question about using Novu with the Java SDK in a self-hosted environment. It seems you're experiencing an issue with payload handling, specifically with the IMPORTANT_NEWS key appearing in the notification payload even when not explicitly sent. Let's explore this based on the available information. First, let's clarify how payload handling typically works in Novu: 1. When triggering an event, you can include a payload with custom variables (1) . These variables can then be used in your notification templates. 2. In the email templates, you're correctly using Handlebars syntax like {{#if NEWS}} to conditionally render content based on the presence of certain payload keys (2) . However, the behavior you're describing, where IMPORTANT_NEWS appears as true even when not sent, is not the expected behavior. This could potentially be related to a known issue with how Novu handles undefined or null values in payloads (3) . Here are a few points to consider: 1. There was a reported bug where Novu was changing undefined or null values to empty strings, which could affect conditional checks . This might be related to your issue, although in your case, it seems the value is appearing as true rather than an empty string. 2. To troubleshoot this, you could try the following: a. Double-check that you're not accidentally including IMPORTANT_NEWS in your payload when you think you're omitting it.
b. Try using a more specific conditional check in your template, such as {{#if IMPORTANT_NEWS.length}} or {{#if IMPORTANT_NEWS.[0]}} to check if the list actually contains any items.
c. Log the
Ask Inkeep
Ask Inkeep6mo ago
entire payload on the server-side just before sending it to Novu to ensure it doesn't contain IMPORTANT_NEWS. 3. If the issue persists, it might be worth checking if there's any caching happening at any level of your application or in Novu itself that could be preserving old payload values. Unfortunately, I couldn't find any documentation or reported issues that exactly match your scenario. Given that you're using a self-hosted version, it's possible that this could be a bug in the specific version you're using. To get more clarity on this issue, I suggest you click on the "Ask for help" button to tag a team member who can review your question in more detail. They might be able to provide more specific guidance or investigate if this is indeed a bug in the version you're using. In the meantime, you could try updating to the latest version of Novu if you haven't already, as it's possible this issue has been resolved in a newer release.
Ask Inkeep
Ask Inkeep6mo ago
Got it. Tagging @Support for additional help.
Pawan Jain
Pawan Jain6mo ago
@Etigma NEWS : [ "new_one" ] IMPORTANT_NEWS : [ "new_two" ] these two fields will be of array type or of boolean type? if these fields will be array type then use gte handlebar helper
{{#gte NEWS.length 0}}
news length is greater than or equal to 0
{{else}}
news length less than 0
{{#gte NEWS.length 0}}
news length is greater than or equal to 0
{{else}}
news length less than 0
@Etigma checkout more comparison helpers as added in this pull request https://github.com/novuhq/novu/pull/5334 I am adding these missing helpers in docs as well
Etigma
EtigmaOP6mo ago
I can use this solution. NEWS should be of type array. But IMPORTANT_NEWS in the tests was not supposed to exist at all. But still is here with a "true" value
Want results from more Discord servers?
Add your server