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

fix: check None before returning config #296

Conversation

mumarkhan999
Copy link
Member

@mumarkhan999 mumarkhan999 commented Aug 4, 2023

Description
While replacing python-memcache with pymemcache ticket link we got the following error

  File "/edx/app/edxapp/edx-platform/xmodule/video_block/video_block.py", line 244, in student_view
    fragment = Fragment(self.get_html())
  File "/edx/app/edxapp/edx-platform/xmodule/video_block/video_block.py", line 355, in get_html
    branding_info = BrandingInfoConfig.get_config().get(user_location)
  File "/edx/app/edxapp/edx-platform/lms/djangoapps/branding/models.py", line 54, in get_config
    return json.loads(info.configuration) if info.enabled else {}
AttributeError: 'NoneType' object has no attribute 'enabled'

The reason of above mentioned error was: django-config-models was returning None.

Which was then used by edx-platform which tries to retrieve values from None

https://github.com/openedx/edx-platform/blob/master/lms/djangoapps/branding/models.py#L54

image

This causes errors. In this PR, we're making sure that ConfigurationModel.current doesn't not return None.

@mumarkhan999 mumarkhan999 force-pushed the umar/make-tight-conditining-of-config-retrieval-from-cache branch 2 times, most recently from 9e166b4 to a7b6a64 Compare August 4, 2023 12:00
@@ -131,7 +131,7 @@ def current(cls, *args):
"""
cache_key = cls.cache_key_name(*args)
cached_response = TieredCache.get_cached_response(cache_key)
if cached_response.is_found:
if cached_response.is_found and cached_response.value is not None:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[inform] The None check was there before at this place. But it was removed when TieredCache was included.

https://github.com/openedx/django-config-models/pull/55/files#diff-89972c71903f4383220fc6ece46180b9c5c52f3467b07de6cc662ae9a546f49aL199-L201

@mumarkhan999 mumarkhan999 force-pushed the umar/make-tight-conditining-of-config-retrieval-from-cache branch from a7b6a64 to f79a4fa Compare August 4, 2023 12:05
@awais786 awais786 self-requested a review August 4, 2023 12:14
@mumarkhan999 mumarkhan999 merged commit 94d7592 into master Aug 7, 2023
5 checks passed
@mumarkhan999 mumarkhan999 deleted the umar/make-tight-conditining-of-config-retrieval-from-cache branch August 7, 2023 09:59
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 this pull request may close these issues.

2 participants