Skip to content

Errors in Scripts are ignored, causing wrong notifications #53

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

Open
sebix opened this issue May 6, 2025 · 0 comments
Open

Errors in Scripts are ignored, causing wrong notifications #53

sebix opened this issue May 6, 2025 · 0 comments

Comments

@sebix
Copy link
Contributor

sebix commented May 6, 2025

Mailgen processes all scripts in alphabetical order and checks the return values of the create_notifications function. The first script that returns a list of EmailNotification objects, stops the iteration.
All scripts can change the context, and in the known installation as well as in the example scripts, the first scripts add information to the context (00add_variables_to_context.py) and change the contact information (e.g., by selecting the most specific one).

However, if one of the scripts throws an exception, it is just skipped (line 152-155):

for script in scripts:
log.debug("Calling script %r", script.filename)
try:
notifications = script(script_context)
except Exception:
log.exception("Error while running entry point of script %r",
script.filename)
continue
else:
log.debug("Script %r finished. Result: %r", script.filename, notifications)
if notifications:
return notifications

That means, though, that the context is different from what was expected, information is missing or wrong, and the notifications will be sent to other recipients or have unwanted content.

@bernhardreiter Is this behaviour by design? If so, why?

I propose to change the behavior to not send directives when any script fails to process it.
We could have an optional parameter (in the configuration file and/or command line flag) to ignore errors for the current behavior.

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

No branches or pull requests

1 participant