fix: Add code_owner decorator to remaining Celery tasks (#31762)

This will ensure that errors raised by these tasks will alert the right
team. `send_course_enrollment_email` is the one I set out to fix, but I
discovered a few others.

I located tasks that were missing decorators by running the following
search and visually inspecting the results, although semgrep might be able
to do better:

```
ack '^@.*task|^@set_code_owner_attribute' cms lms common openedx xmodule --ignore-dir=tests --python
```

Also, add more detailed explanation of why a couple of tasks can't use the
decorator. This should only be an issue on tasks inheriting from
UserTaskMixin, which in practice is just CourseExportTask and
CourseImportTask (and the apparently unused EnrollmentReadTask and
EnrollmentWriteTask), via UserTask.
This commit is contained in:
Tim McCormack
2023-02-15 18:20:50 +00:00
committed by GitHub
parent 197fef9c2b
commit 83f6e560b7
7 changed files with 20 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import logging
from celery import shared_task
from django.conf import settings
from django.contrib.auth import get_user_model
from edx_django_utils.monitoring import set_code_owner_attribute
from opaque_keys.edx.keys import CourseKey
from common.djangoapps.track import segment
@@ -30,6 +31,7 @@ COUNTDOWN = 60
@shared_task(bind=True, ignore_result=True)
@set_code_owner_attribute
def send_course_enrollment_email(
self, user_id, course_id, course_title, short_description, course_ended, pacing_type, track_mode
):