-
Notifications
You must be signed in to change notification settings - Fork 25
#3523: Standardize all failed email logger error messages - [RH] #3937
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
base: main
Are you sure you want to change the base?
Conversation
🥳 Successfully deployed to developer sandbox rh. |
🥳 Successfully deployed to developer sandbox rh. |
… rh/3523-standardize
🥳 Successfully deployed to developer sandbox rh. |
1 similar comment
🥳 Successfully deployed to developer sandbox rh. |
Noticed calling
|
Clarifying question: do we want to log the name of the file where we're storing our email subjects or the subject text? I noticed we're logging the filenames eg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comments while I'm going through the rest of these! happy to go over them on slack and
f"email did not send successfully to {email_data['email']} " | ||
f"for {[domain for domain in email_data['domains']]}" | ||
f": {err}" | ||
"Failed to send transition domain invitation email:\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got the following error when trying to test this script and prompting an error. I did this locally by automatically throwing an EmailSendingError in the try block's first line. For setup, I created a transition domain and tried running the script to prompt the email error but let me know if I did anything different from its expected use!
Traceback (most recent call last):
File "/app/registrar/management/commands/send_domain_invitations.py", line 124, in send_email
raise EmailSendingError
registrar.utility.email.EmailSendingError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/./manage.py", line 20, in <module>
main()
File "/app/./manage.py", line 16, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
File "/app/registrar/management/commands/send_domain_invitations.py", line 66, in handle
self.send_emails()
File "/app/registrar/management/commands/send_domain_invitations.py", line 115, in send_emails
self.send_email(email_data)
File "/app/registrar/management/commands/send_domain_invitations.py", line 141, in send_email
f" Subject: {email_data['subject']}\n"
KeyError: 'subject'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my gosh great catch - I will edit the line to f" Subject: transition_domain_invitation_subject.txt\n"
as we have the subject above, and the way I was trying to pull that info is incorrect
@@ -975,7 +975,7 @@ def _send_status_update_email( | |||
|
|||
context: dict -> The context sent to the template | |||
|
|||
send_email: bool -> Used to bypass the send_templated_email function, in the event | |||
send_email: bool -> Used to bypass the function, in the event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we remove the function name here / don't replace it with another function name if send_templated_email is inaccurate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WHEW another great catch, this was an accident and will add back
f" Subject: {email_template_subject}\n" | ||
f" To: {recipient.email}\n" | ||
f" CC: {', '.join(cc_addresses)}\n" | ||
f" BCC: {bcc_address}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this comma needs to be removed and replaced with a newline! I think it leads to an error in the fstring because the compiler thinks that next part of the fstring is an art to logger.error
app-1 | File "/app/registrar/models/domain_request.py", line 1097, in submit
app-1 | self._send_status_update_email(
app-1 | File "/app/registrar/models/domain_request.py", line 1037, in _send_status_update_email
app-1 | logger.error(
app-1 | Message: 'Failed to send status update to creator email:\n Type: submission confirmation\n Subject: emails/submission_confirmation_subject.txt\n To: [email protected]\n CC: \n BCC: '
app-1 | Arguments: (' Error: ',)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested everything else and error messages are updated. thank you for cleaning this up! just had a few comments from the earlier pass
"Could not send notification email to %s for domain %s", | ||
user.email, | ||
domain.name, | ||
except EmailSendingError as err: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be out of scope but I noticed when we fail to email domain managers that a manager has been added, we add an alert saying so
But when we remove a domain manager and fail to email the other domain managers, that update doesn't show
Are the alert error messages also in scope of this ticket or is that separate? We can create another ticket if it is out of scope!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create another ticket as this one is focused just on logs and not the error displays! Another great catch btw!!! 💯
@erinysong I opted to go with the |
🥳 Successfully deployed to developer sandbox rh. |
1 similar comment
🥳 Successfully deployed to developer sandbox rh. |
Ah sorry I meant to hit "dismiss review" and not "re-request review" bc I had added in the new changes/feedback, sorry!
Got it thank you! Totally get that since we read the subject line elsewhere. Just out of curiosity, have we tried running django.template.loader's If that doesn't work I'm thinking we can change that field name in the logs to "Subject template" (what we call the param in send_templated_email) since that's a more accurate description of what we're displaying in the log |
Ticket
Resolves #3523
Changes
Context for reviewers
We are hoping to add more information to loggers when emails don't send out. They are now all logger.errors and have clearer error messages.
Setup
Code Review Verification Steps
As the original developer, I have
Satisfied acceptance criteria and met development standards
Ensured code standards are met (Original Developer)
Validated user-facing changes (if applicable)
As a code reviewer, I have
Reviewed, tested, and left feedback about the changes
Validated user-facing changes as a developer
Note: Multiple code reviewers can share the checklists above, a second reviewer should not make a duplicate checklist. All checks should be checked before approving, even those labeled N/A.
As a designer reviewer, I have
Verified that the changes match the design intention
Validated user-facing changes as a designer
References
Screenshots