Issue when accessing a program: AttributeError: 'NoneType' object has no attribute 'grade_cutoffs'

Hi all, we are experience this error when we try to load a program in the LMS (/dashboard/programs/{program-uuid}/, we run “cache_programs” to load program data from discovery service.

This is the error stacktrace:

69996-2019-11-21 14:29:33,619 ERROR 11 [django.request] exception.py:135 - Internal Server Error: /dashboard/programs/9a1f94ff-1cdb-418a-b223-3b58e7a474b6/
69997-Traceback (most recent call last):
69998-  File "/openedx/venv/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
69999-    response = get_response(request)
70000-  File "/openedx/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
70001-    response = self._get_response(request)
70002-  File "/openedx/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
70003-    response = self.process_exception_by_middleware(e, request)
70004-  File "/openedx/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
70005-    response = wrapped_callback(request, *callback_args, **callback_kwargs)
70006-  File "/openedx/venv/local/lib/python2.7/site-packages/django/utils/decorators.py", line 185, in inner
70007-    return func(*args, **kwargs)
70008-  File "/openedx/venv/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
70009-    return view_func(request, *args, **kwargs)
70010-  File "/openedx/venv/local/lib/python2.7/site-packages/django/views/decorators/http.py", line 40, in inner
70011-    return func(request, *args, **kwargs)
70012-  File "/openedx/edx-platform/lms/djangoapps/learner_dashboard/views.py", line 38, in program_details
70013-    request, program_uuid, programs_config=programs_config
70014-  File "/openedx/edx-platform/lms/djangoapps/learner_dashboard/programs.py", line 96, in render_to_fragment
70015-    course_data = meter.progress(programs=[program_data], count_only=False)[0]
70016-  File "/openedx/edx-platform/openedx/core/djangoapps/programs/utils.py", line 267, in progress
70017-    grade = self.course_grade_factory.read(self.user, course_key=CourseKey.from_string(run))
70018-  File "/openedx/edx-platform/lms/djangoapps/grades/course_grade_factory.py", line 51, in read
70019-    return self._update(user, course_data)
70020-  File "/openedx/edx-platform/lms/djangoapps/grades/course_grade_factory.py", line 178, in _update
70021-    course_grade = course_grade.update()
70022-  File "/openedx/edx-platform/lms/djangoapps/grades/course_grade.py", line 259, in update
70023:    grade_cutoffs = self.course_data.course.grade_cutoffs
70024:AttributeError: 'NoneType' object has no attribute 'grade_cutoffs'

We find one way to by pass the error, if we go to the cms and we re-set the grades to the courses that are included in the program, we can access the program. But after restarting the LMS the same error happens. So, the only way around that we have by now it to re-save the grades for each course in the program after we recreate the cache.

Any ideas of this issue? Thanks a lot.

Hi @cacciaresi. From that stack trace, the self.course_data.course attribute is null. That property should be looking in the modulestore for the given course key if a course attribute hasn’t previously been cached: https://github.com/edx/edx-platform/blob/master/lms/djangoapps/grades/course_data.py#L76-L80

My guess is that the course key in your discovery service doesn’t exist in the LMS/CMS modulestore - maybe one is slightly different from the other?

2 Likes

I think that I’m running ironwood.2 in discovery and ironwood.master in lms, maybe that can be the problem?

Thanks a lot for your help.

This issue happen again to us… we are running cache_programs every 30 minutes.

If anyone receive this error in the past, please let me know.

Thanks.