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

Fix notification for background tasks with no verbose_name #2091

Merged
merged 1 commit into from
Sep 26, 2023

Conversation

bemoody
Copy link
Collaborator

@bemoody bemoody commented Sep 26, 2023

Background tasks can be created with a "verbose name" which provides a human-readable description. This is what the existing background tasks (mostly implemented by Felipe) all do, and the verbose name is used when sending email notifications.

However, if a task is created without an explicit verbose_name (as is done in pull #2086), the verbose_name is set to None, which causes the email notification functions to crash.

It's best to use a verbose_name, but if we don't do so, we still want the notifications to work. :)

When notifying about a failed or rescheduled task, if the task was
created without a "verbose_name", use its "task_name" instead.

(See console.tasks.task_rescheduled_handler and
console.tasks.task_failed_handler, and note that verbose_name is
nullable whereas task_name isn't.)

When you create a task, specifying a verbose_name is recommended, as
it can provide more human-readable information than the task_name and
task_params.  However, if no verbose_name is provided, we still need
something to put in the email subject.
@tompollard
Copy link
Member

good catch!

@tompollard tompollard merged commit 76536b1 into dev Sep 26, 2023
8 checks passed
@tompollard tompollard deleted the notify-nameless-tasks branch September 26, 2023 21:23
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

Successfully merging this pull request may close these issues.

2 participants