mitodl / micromasters

Portal for learners and course teams to access MITx Micromasters® programs
https://mm.mit.edu
BSD 3-Clause "New" or "Revised" License
28 stars 16 forks source link

Course.MultipleObjectsReturned: get() returned more than one Course -- it returned 8! #5237

Closed sentry-io[bot] closed 1 year ago

sentry-io[bot] commented 1 year ago

Sentry Issue: MICROMASTERS-64P

Course.MultipleObjectsReturned: get() returned more than one Course -- it returned 8!
(5 additional frame(s) were not displayed)
...
  File "dashboard/api.py", line 274, in <listcomp>
    run_statuses = [get_status_for_courserun(course_run, mmtrack)
  File "dashboard/api.py", line 399, in get_status_for_courserun
    if mmtrack.has_paid(course_run.edx_course_key):
  File "dashboard/utils.py", line 225, in has_paid
    course = Course.objects.get(courserun__edx_course_key=edx_course_key)
  File "django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "django/db/models/query.py", line 410, in get
    raise self.model.MultipleObjectsReturned(

An exception was intercepted by custom_exception_handler
arslanashraf7 commented 1 year ago

We had multiple course runs with None/empty edX course keys and when the code would hit this line with an empty edX course key to look it would break.

I think we need to create a PR to fix this, I confirmed with @pdpinch that a course run with no edx course key will not have a paid status in general.

arslanashraf7 commented 1 year ago

Closed via #5238