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

TypeError: Field 'id' expected a number but got <django.contrib.auth.models.AnonymousUser object at 0x7f2ab6... #301

Closed
sentry-io bot opened this issue Oct 31, 2022 · 5 comments · Fixed by mitodl/ol-infrastructure#1192
Assignees

Comments

@sentry-io
Copy link

sentry-io bot commented Oct 31, 2022

Sentry Issue: OPENEDX-RESIDENTIAL-50B

KeyError: 'grades_cache.course-v1:MITx+8.01+2022_Fall'
  File "lms/djangoapps/grades/models.py", line 620, in read
    prefetched_grades = get_cache(cls._CACHE_NAMESPACE)[cls._cache_key(course_id)]

PersistentCourseGrade.DoesNotExist: PersistentCourseGrade matching query does not exist.
  File "lms/djangoapps/grades/course_grade_factory.py", line 50, in read
    return self._read(user, course_data)
  File "lms/djangoapps/grades/course_grade_factory.py", line 152, in _read
    persistent_grade = PersistentCourseGrade.read(user.id, course_data.course_key)
  File "lms/djangoapps/grades/models.py", line 629, in read
    return cls.objects.get(user_id=user_id, course_id=course_id)
  File "django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(

TypeError: Cannot cast AnonymousUser to int. Are you trying to use it in place of User?
  File "django/db/models/fields/__init__.py", line 1823, in get_prep_value
    return int(value)
  File "django/contrib/auth/models.py", line 420, in __int__
    raise TypeError('Cannot cast AnonymousUser to int. Are you trying to use it in place of User?')

TypeError: Field 'id' expected a number but got <django.contrib.auth.models.AnonymousUser object at 0x7f2ab6c48f10>.
(32 additional frame(s) were not displayed)
...
  File "django/db/models/sql/query.py", line 1370, in build_filter
    condition = self.build_lookup(lookups, col, value)
  File "django/db/models/sql/query.py", line 1216, in build_lookup
    lookup = lookup_class(lhs, rhs)
  File "django/db/models/lookups.py", line 25, in __init__
    self.rhs = self.get_prep_lookup()
  File "django/db/models/fields/related_lookups.py", line 117, in get_prep_lookup
    self.rhs = target_field.get_prep_value(self.rhs)
  File "django/db/models/fields/__init__.py", line 1825, in get_prep_value
    raise e.__class__(
@pdpinch
Copy link
Member

pdpinch commented Oct 31, 2022

Possibly related, judging by the error message: openedx/axim-engineering#443 (comment)

@asadali145
Copy link

Hey @pdpinch,
Before Olive, we can simply set a feature flag settings.FEATURES[“ASSUME_ZERO_GRADE_IF_ABSENT_FOR_ALL_TESTS”] to True. This will enable zero grades feature that is also the default behaviour in Olive. It will resolve the above issue.

We do not need to do anything with the Milestones app if we haven't enabled Entrance Exams for the anonymously available courseware. Everything should work fine after the above feature flag.

@blarghmatey Could you please guide me like where to add the above feature flag for residential MITx?
Thanks

@asadali145
Copy link

Could someone from @mitodl/devops help with the above setting?

@arslanashraf7
Copy link

arslanashraf7 commented Nov 1, 2022

Could someone from @mitodl/devops help with the above setting?

This is the idea i had about these but definitely wait on devops to see if there might be other places for this.

There are two differnt files for the features settings for MITx. I think this will nee to be added in both or we can add it in staging first, test it and then add to producution file too. The references are mitx/common_values.yml.tmpl and mitx-staging/common_values.yml.tmpl.

@blarghmatey
Copy link
Member

For residential the setting can be added to the common_settings.yml.tmpl in the mitx and mitx-staging directories under https://github.com/mitodl/ol-infrastructure/tree/main/src/bilder/images/edxapp/templates/edxapp

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 a pull request may close this issue.

4 participants