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

Email with custom notifications not working #13983

Open
5 of 10 tasks
trevorl-dtl opened this issue May 11, 2023 · 5 comments
Open
5 of 10 tasks

Email with custom notifications not working #13983

trevorl-dtl opened this issue May 11, 2023 · 5 comments

Comments

@trevorl-dtl
Copy link

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that AWX is open source software provided for free and that I might not receive a timely response.
  • I am NOT reporting a (potential) security vulnerability. (These should be emailed to security@ansible.com instead.)

Bug Summary

Inputting valid attributes into custom notifications results in email being blank.

AWX version

22.1.0

Select the relevant components

  • UI
  • API
  • Docs
  • Collection
  • CLI
  • Other

Installation method

kubernetes

Modifications

no

Ansible version

No response

Operating system

No response

Web browser

No response

Steps to reproduce

image

image

Expected results

The user who ran the job should appear with the job name.

Actual results

Email is sent blank.

Additional information

No response

@trevorl-dtl
Copy link
Author

Issue still present in 22.2.0

@trevorl-dtl
Copy link
Author

Issue still present in 23.0.0

@kurokobo
Copy link
Contributor

kurokobo commented Sep 26, 2023

For workflow pending message, job is undefined.

  • Configuration:
    • image
  • Result:
    • image

Reffering properties of undefined variables causes completely empty mail.

  • Configuration:
    • image
  • Result:
    • image

Thus, the error handling during creating the notification message should be improved.
As a temporary workaround, just avoid using undefined variables.

@trevorl-dtl
Copy link
Author

I see, thanks for the info! Shame that this is still broken, but will wait for a fix to hopefully come around soon.

@kurokobo
Copy link
Contributor

In the current implementation, it seems to be designed behavior that return empty string if any errors are occurred during templating custom message fields. This is an understandable implementation, since the complex Jinja2 syntax makes it difficult to ignore only where errors occur.

if msg_template:
try:
msg = env.from_string(msg_template).render(**context)
except (TemplateSyntaxError, UndefinedError, SecurityError):
msg = ''
if body_template:
try:
body = env.from_string(body_template).render(**context)
except (TemplateSyntaxError, UndefinedError, SecurityError):
body = ''

However, if the body for the mail is an empty string, there appears to be a lack of line breaks at the end of the source of the email being sent.

This seems to prevent some email clients from interpreting the email as valid, and this causes the correctly templated subject line to be ignored.

image

Just add one line break and at least the subject line will appear (kurokobo@4ae8ed5).

image

The options we can take are as follows

  1. Ensure that when a message is empty, it contains at least one line break
  2. When an error occurs during rendering the message, return a user-friendly error message e.g. "please contact administrator" instead of an empty string,
  3. Validate usable variables for each fields when editing it (hard way)
  4. Keep everything as-is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants