From 53d3581e248e864d0305aeda1b91bce5359885c7 Mon Sep 17 00:00:00 2001 From: Jillian Vogel Date: Thu, 24 Oct 2024 14:33:27 +1030 Subject: [PATCH 1/3] fix: wrap call to storage path in NotImplementedError Admin page calls contents.os_path(), and if the storage backend doesn't support `path`, we can't even load the admin page for that asset. --- openedx_learning/apps/authoring/contents/models.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/openedx_learning/apps/authoring/contents/models.py b/openedx_learning/apps/authoring/contents/models.py index 214c2d27..d1c07624 100644 --- a/openedx_learning/apps/authoring/contents/models.py +++ b/openedx_learning/apps/authoring/contents/models.py @@ -6,6 +6,7 @@ from __future__ import annotations from functools import cache, cached_property +from logging import getLogger from django.conf import settings from django.core.exceptions import ImproperlyConfigured, ValidationError @@ -19,6 +20,8 @@ from ....lib.managers import WithRelationsManager from ..publishing.models import LearningPackage +logger = getLogger() + __all__ = [ "MediaType", "Content", @@ -316,8 +319,11 @@ def os_path(self): This will return ``None`` if there is no backing file (has_file=False). """ - if self.has_file: - return get_storage().path(self.path) + try: + if self.has_file: + return get_storage().path(self.path) + except NotImplementedError as err: + logger.exception(err) return None def read_file(self) -> File: From 6ac94d151ce7099a54234505ed270da0066ca4c5 Mon Sep 17 00:00:00 2001 From: Jillian Vogel Date: Fri, 25 Oct 2024 11:45:17 +1030 Subject: [PATCH 2/3] chore: bump version to 0.16.2 --- openedx_learning/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openedx_learning/__init__.py b/openedx_learning/__init__.py index d15f8e48..e4d85ebf 100644 --- a/openedx_learning/__init__.py +++ b/openedx_learning/__init__.py @@ -2,4 +2,4 @@ Open edX Learning ("Learning Core"). """ -__version__ = "0.16.1" +__version__ = "0.16.2" From 16781fecffb1cb12fb7e80d7bdf714a28692f562 Mon Sep 17 00:00:00 2001 From: Jillian Vogel Date: Fri, 25 Oct 2024 12:28:31 +1030 Subject: [PATCH 3/3] fix: log.warning instead of log.exception --- openedx_learning/apps/authoring/contents/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openedx_learning/apps/authoring/contents/models.py b/openedx_learning/apps/authoring/contents/models.py index d1c07624..f641629c 100644 --- a/openedx_learning/apps/authoring/contents/models.py +++ b/openedx_learning/apps/authoring/contents/models.py @@ -322,8 +322,8 @@ def os_path(self): try: if self.has_file: return get_storage().path(self.path) - except NotImplementedError as err: - logger.exception(err) + except NotImplementedError: + logger.warning("Storage backend does not support path()") return None def read_file(self) -> File: