Provide string backups for possible empty fields in PD MailJet emails #68163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The issue of why certain MailJet emails weren't sending was likely that
nil
fields weren't able to be processed by MailJet, which expects string values. Since I was testing the 3-/10-day reminder and the post-workshop survey emails locally, I always included the test regional partner and test facilitator I created locally out of habit since I knew they wouldn't actually receive emails (since the emails were fake). However, when I tested on production, I didn't use a regional partner or facilitator in the workshops because I didn't want to send real RP's and facilitators test emails, and I believe this caused therp_name
,facilitator_names
, etc. variables to benil
rather than empty strings which threw an error in the email.Production investigation
I was able to confirm this on production and locally when manually triggering

send_exit_surveys
. When there was an empty field (such asrp_name
), MailJet threw an error:However, once those fields were filled in and I tried again, I saw a success (and an email in my inbox):

Test locally
I created a workshop with the bare minimum fields it would let me create it with to test.
I first confirmed that locally I would see the same error with missing fields:

Then, I added fallback string values for fields that could possibly be

nil
and tested again (this time, seeing the email):This PR's changes
This PR adds in the fallback values but still keeps sending the post-workshop survey behind the DCDO flag just to be safe. Once I can confirm that it's working on production as expected, we can do the rollout of the new MailJet email for all users.
Links
Jira ticket: here
Testing story
Local testing.
Follow-up work
Once I confirm this works on production as well, we can start rolling out the new PD MailJet emails.