From 3da9362ac80896803dfbf44cd3f25d4bd35c0eb7 Mon Sep 17 00:00:00 2001 From: stvn Date: Wed, 22 Jul 2020 13:27:36 -0700 Subject: [PATCH] Log and skip empty children when rendering library_content instead of throwing an exception on None-access. --- common/lib/xmodule/xmodule/library_content_module.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/lib/xmodule/xmodule/library_content_module.py b/common/lib/xmodule/xmodule/library_content_module.py index fd58beaeea..d796e870c3 100644 --- a/common/lib/xmodule/xmodule/library_content_module.py +++ b/common/lib/xmodule/xmodule/library_content_module.py @@ -315,6 +315,15 @@ class LibraryContentModule(LibraryContentFields, XModule, StudioEditableModule): child_context = {} if not context else copy(context) for child in self._get_selected_child_blocks(): + if child is None: + # TODO: Fix the underlying issue in TNL-7424 + # This shouldn't be happening, but does for an as-of-now + # unknown reason. Until we address the underlying issue, + # let's at least log the error explicitly, ignore the + # exception, and prevent the page from resulting in a + # 500-response. + logger.error('Skipping display for child block that is None') + continue for displayable in child.displayable_items(): rendered_child = displayable.render(STUDENT_VIEW, child_context) fragment.add_fragment_resources(rendered_child)