Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2286 missing e-mail subject personalisation errors #2290

Merged
merged 7 commits into from
Feb 6, 2025

Conversation

kalbfled
Copy link
Member

@kalbfled kalbfled commented Feb 6, 2025

Description

These changes add unit tests and pull in an updated version of Utils. (See the Utils PR.) The goal is that requests to send e-mail using a template with a placeholder in the subject return 400 if the POST data doesn't contain an associated value. The problem was that Utils was only checking for missing values in the content body.

How Has This Been Tested?

I repeated that steps in the ticket to reproduce the problem and observed that it's no longer a problem.

Happy path with template b2c9ff49-b37b-4352-ab0c-3d3d0710fe4c:
image

Missing subject data:
image

Missing content data:
image

Missing subject data with template 64b0953c-b7ea-4b48-b70f-d242ce5b17d2, which only has a placeholder in the subject:
image

Checklist

  • I have assigned myself to this PR
  • PR has an appropriate title: #9999 - What the thing does
  • PR has a detailed description, including links to specific documentation
  • I have added the appropriate labels to the PR.
  • I did not remove any parts of the template, such as checkboxes even if they are not used
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to any documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works. Testing guidelines
  • I have ensured the latest main is merged into my branch and all checks are green prior to review
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • The ticket was moved into the DEV test column when I began testing this change

message = 'Missing personalisation: {}'.format(', '.join(template_object.missing_data))
def check_placeholders(utils_template_instance):
if utils_template_instance.missing_data:
message = 'Missing personalisation: {}'.format(', '.join(utils_template_instance.missing_data))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: since we are here, can we just convert this to f-string format?

Suggested change
message = 'Missing personalisation: {}'.format(', '.join(utils_template_instance.missing_data))
message = f"Missing personalisation: {', '.join(utils_template_instance.missing_data)}"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, given that the substitution is an expression and not just a variable, I think it's more readable with "format."

Copy link

@cris-oddball cris-oddball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with one small nit

Copy link

@MackHalliday MackHalliday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved - cross reference with AC

@kalbfled kalbfled force-pushed the 2286-subject-placeholders branch from ff9a3d6 to 733f7d3 Compare February 6, 2025 17:52
@EvanParish EvanParish merged commit 5040f32 into main Feb 6, 2025
5 checks passed
@EvanParish EvanParish deleted the 2286-subject-placeholders branch February 6, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants