Hi,
We had anonymous site access working, but right now all we are seeing is “There was an error loading this course.”
Looking at the LMS logs an exception seems to be happening for the course grades? Any idea on what might be causing this or how to fix it?
Thanks!
lms_1 | 2022-08-11 21:57:32,365 ERROR 7 [root] [user None] [ip None] signals.py:22 - Uncaught exception from None
lms_1 | Traceback (most recent call last):
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/grades/models.py", line 620, in read
lms_1 | prefetched_grades = get_cache(cls._CACHE_NAMESPACE)[cls._cache_key(course_id)]
lms_1 | KeyError: 'grades_cache.course-v1:NLA+IL1010+20_21'
lms_1 |
lms_1 | During handling of the above exception, another exception occurred:
lms_1 |
lms_1 | Traceback (most recent call last):
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/grades/course_grade_factory.py", line 50, in read
lms_1 | return self._read(user, course_data)
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/grades/course_grade_factory.py", line 152, in _read
lms_1 | persistent_grade = PersistentCourseGrade.read(user.id, course_data.course_key)
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/grades/models.py", line 629, in read
lms_1 | return cls.objects.get(user_id=user_id, course_id=course_id)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
lms_1 | return getattr(self.get_queryset(), name)(*args, **kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 435, in get
lms_1 | raise self.model.DoesNotExist(
lms_1 | lms.djangoapps.grades.models.PersistentCourseGrade.DoesNotExist: PersistentCourseGrade matching query does not exist.
lms_1 |
lms_1 | During handling of the above exception, another exception occurred:
lms_1 |
lms_1 | Traceback (most recent call last):
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 1823, in get_prep_value
lms_1 | return int(value)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/contrib/auth/models.py", line 420, in __int__
lms_1 | raise TypeError('Cannot cast AnonymousUser to int. Are you trying to use it in place of User?')
lms_1 | TypeError: Cannot cast AnonymousUser to int. Are you trying to use it in place of User?
lms_1 |
lms_1 | The above exception was the direct cause of the following exception:
lms_1 |
lms_1 | Traceback (most recent call last):
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
lms_1 | response = get_response(request)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
lms_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs)
lms_1 | File "/opt/pyenv/versions/3.8.12/lib/python3.8/contextlib.py", line 75, in inner
lms_1 | return func(*args, **kwds)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
lms_1 | return view_func(*args, **kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
lms_1 | return self.dispatch(request, *args, **kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
lms_1 | response = self.handle_exception(exc)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
lms_1 | self.raise_uncaught_exception(exc)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
lms_1 | raise exc
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
lms_1 | response = handler(request, *args, **kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/generics.py", line 208, in get
lms_1 | return self.retrieve(request, *args, **kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/mixins.py", line 56, in retrieve
lms_1 | return Response(serializer.data)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/serializers.py", line 548, in data
lms_1 | ret = super().data
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/serializers.py", line 246, in data
lms_1 | self._data = self.to_representation(self.instance)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/serializers.py", line 502, in to_representation
lms_1 | attribute = field.get_attribute(instance)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/fields.py", line 457, in get_attribute
lms_1 | return get_attribute(instance, self.source_attrs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/fields.py", line 97, in get_attribute
lms_1 | instance = getattr(instance, attr)
lms_1 | File "/openedx/edx-platform/./openedx/core/djangoapps/courseware_api/views.py", line 221, in entrance_exam_data
lms_1 | self.course_grade, get_entrance_exam_usage_key(self.overview),
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
lms_1 | res = instance.__dict__[self.name] = self.func(instance)
lms_1 | File "/openedx/edx-platform/./openedx/core/djangoapps/courseware_api/views.py", line 187, in course_grade
lms_1 | return CourseGradeFactory().read(self.effective_user, self.course)
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/grades/course_grade_factory.py", line 55, in read
lms_1 | return self._update(user, course_data, send_course_grade_signals=send_course_grade_signals)
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/grades/course_grade_factory.py", line 215, in _update
lms_1 | COURSE_GRADE_NOW_FAILED.send(
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 180, in send
lms_1 | return [
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 181, in <listcomp>
lms_1 | (receiver, receiver(signal=self, sender=sender, **named))
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/certificates/signals.py", line 92, in _listen_for_failing_grade
lms_1 | if is_on_certificate_allowlist(user, course_id):
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/certificates/generation_handler.py", line 321, in is_on_certificate_allowlist
lms_1 | return CertificateAllowlist.objects.filter(user=user, course_id=course_key, allowlist=True).exists()
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
lms_1 | return getattr(self.get_queryset(), name)(*args, **kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 941, in filter
lms_1 | return self._filter_or_exclude(False, args, kwargs)
lms_1 | File "/openedx/edx-platform/./openedx/core/djangoapps/xmodule_django/models.py", line 47, in _filter_or_exclude
lms_1 | return super()._filter_or_exclude(*args, **kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 961, in _filter_or_exclude
lms_1 | clone._filter_or_exclude_inplace(negate, args, kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 968, in _filter_or_exclude_inplace
lms_1 | self._query.add_q(Q(*args, **kwargs))
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1416, in add_q
lms_1 | clause, _ = self._add_q(q_object, self.used_aliases)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1435, in _add_q
lms_1 | child_clause, needed_inner = self.build_filter(
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1370, in build_filter
lms_1 | condition = self.build_lookup(lookups, col, value)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1216, in build_lookup
lms_1 | lookup = lookup_class(lhs, rhs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/lookups.py", line 25, in __init__
lms_1 | self.rhs = self.get_prep_lookup()
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/fields/related_lookups.py", line 117, in get_prep_lookup
lms_1 | self.rhs = target_field.get_prep_value(self.rhs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 1825, in get_prep_value
lms_1 | raise e.__class__(
lms_1 | TypeError: Field 'id' expected a number but got <django.contrib.auth.models.AnonymousUser object at 0x7f00def74f40>.
lms_1 | [pid: 19|app: 0|req: 2869/6999] 172.18.0.5 () {56 vars in 1339 bytes} [Thu Aug 11 21:57:32 2022] GET /api/courseware/sequence/block-v1:NLA+IL1010+20_21+type@sequential+block@aabc642aab3f44ffb7d96af6e3512e81 => generated 4283 bytes in 448 msecs (HTTP/1.1 200) 8 headers in 306 bytes (1 switches on core 0)
lms_1 | 2022-08-11 21:57:32,486 ERROR 7 [django.request] [user None] [ip 129.130.19.148] log.py:224 - Internal Server Error: /api/courseware/course/course-v1:NLA+IL1010+20_21
lms_1 | Traceback (most recent call last):
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/grades/models.py", line 620, in read
lms_1 | prefetched_grades = get_cache(cls._CACHE_NAMESPACE)[cls._cache_key(course_id)]
lms_1 | KeyError: 'grades_cache.course-v1:NLA+IL1010+20_21'
lms_1 |
lms_1 | During handling of the above exception, another exception occurred:
lms_1 |
lms_1 | Traceback (most recent call last):
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/grades/course_grade_factory.py", line 50, in read
lms_1 | return self._read(user, course_data)
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/grades/course_grade_factory.py", line 152, in _read
lms_1 | persistent_grade = PersistentCourseGrade.read(user.id, course_data.course_key)
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/grades/models.py", line 629, in read
lms_1 | return cls.objects.get(user_id=user_id, course_id=course_id)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
lms_1 | return getattr(self.get_queryset(), name)(*args, **kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 435, in get
lms_1 | raise self.model.DoesNotExist(
lms_1 | lms.djangoapps.grades.models.PersistentCourseGrade.DoesNotExist: PersistentCourseGrade matching query does not exist.
lms_1 |
lms_1 | During handling of the above exception, another exception occurred:
lms_1 |
lms_1 | Traceback (most recent call last):
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 1823, in get_prep_value
lms_1 | return int(value)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/contrib/auth/models.py", line 420, in __int__
lms_1 | raise TypeError('Cannot cast AnonymousUser to int. Are you trying to use it in place of User?')
lms_1 | TypeError: Cannot cast AnonymousUser to int. Are you trying to use it in place of User?
lms_1 |
lms_1 | The above exception was the direct cause of the following exception:
lms_1 |
lms_1 | Traceback (most recent call last):
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
lms_1 | response = get_response(request)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
lms_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs)
lms_1 | File "/opt/pyenv/versions/3.8.12/lib/python3.8/contextlib.py", line 75, in inner
lms_1 | return func(*args, **kwds)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
lms_1 | return view_func(*args, **kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
lms_1 | return self.dispatch(request, *args, **kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
lms_1 | response = self.handle_exception(exc)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
lms_1 | self.raise_uncaught_exception(exc)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
lms_1 | raise exc
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
lms_1 | response = handler(request, *args, **kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/generics.py", line 208, in get
lms_1 | return self.retrieve(request, *args, **kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/mixins.py", line 56, in retrieve
lms_1 | return Response(serializer.data)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/serializers.py", line 548, in data
lms_1 | ret = super().data
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/serializers.py", line 246, in data
lms_1 | self._data = self.to_representation(self.instance)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/serializers.py", line 502, in to_representation
lms_1 | attribute = field.get_attribute(instance)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/fields.py", line 457, in get_attribute
lms_1 | return get_attribute(instance, self.source_attrs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/rest_framework/fields.py", line 97, in get_attribute
lms_1 | instance = getattr(instance, attr)
lms_1 | File "/openedx/edx-platform/./openedx/core/djangoapps/courseware_api/views.py", line 221, in entrance_exam_data
lms_1 | self.course_grade, get_entrance_exam_usage_key(self.overview),
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
lms_1 | res = instance.__dict__[self.name] = self.func(instance)
lms_1 | File "/openedx/edx-platform/./openedx/core/djangoapps/courseware_api/views.py", line 187, in course_grade
lms_1 | return CourseGradeFactory().read(self.effective_user, self.course)
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/grades/course_grade_factory.py", line 55, in read
lms_1 | return self._update(user, course_data, send_course_grade_signals=send_course_grade_signals)
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/grades/course_grade_factory.py", line 215, in _update
lms_1 | COURSE_GRADE_NOW_FAILED.send(
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 180, in send
lms_1 | return [
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 181, in <listcomp>
lms_1 | (receiver, receiver(signal=self, sender=sender, **named))
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/certificates/signals.py", line 92, in _listen_for_failing_grade
lms_1 | if is_on_certificate_allowlist(user, course_id):
lms_1 | File "/openedx/edx-platform/./lms/djangoapps/certificates/generation_handler.py", line 321, in is_on_certificate_allowlist
lms_1 | return CertificateAllowlist.objects.filter(user=user, course_id=course_key, allowlist=True).exists()
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
lms_1 | return getattr(self.get_queryset(), name)(*args, **kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 941, in filter
lms_1 | return self._filter_or_exclude(False, args, kwargs)
lms_1 | File "/openedx/edx-platform/./openedx/core/djangoapps/xmodule_django/models.py", line 47, in _filter_or_exclude
lms_1 | return super()._filter_or_exclude(*args, **kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 961, in _filter_or_exclude
lms_1 | clone._filter_or_exclude_inplace(negate, args, kwargs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 968, in _filter_or_exclude_inplace
lms_1 | self._query.add_q(Q(*args, **kwargs))
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1416, in add_q
lms_1 | clause, _ = self._add_q(q_object, self.used_aliases)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1435, in _add_q
lms_1 | child_clause, needed_inner = self.build_filter(
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1370, in build_filter
lms_1 | condition = self.build_lookup(lookups, col, value)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1216, in build_lookup
lms_1 | lookup = lookup_class(lhs, rhs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/lookups.py", line 25, in __init__
lms_1 | self.rhs = self.get_prep_lookup()
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/fields/related_lookups.py", line 117, in get_prep_lookup
lms_1 | self.rhs = target_field.get_prep_value(self.rhs)
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 1825, in get_prep_value
lms_1 | raise e.__class__(
lms_1 | TypeError: Field 'id' expected a number but got <django.contrib.auth.models.AnonymousUser object at 0x7f00def74f40>.