From e09a5c9d94ef90bbba10f30fe647554bbfc29104 Mon Sep 17 00:00:00 2001 From: stvn Date: Wed, 27 Jan 2021 11:24:12 -0800 Subject: [PATCH] fix: Fix KeyError in vertical_block This now mimics the way this is (safely) done in the sequence module [1]. References: - [1] https://github.com/edx/edx-platform/blob/5f94a082ce1141d9214e83c152baa00186278ad3/common/lib/xmodule/xmodule/seq_module.py#L657-L658 --- common/lib/xmodule/xmodule/vertical_block.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/vertical_block.py b/common/lib/xmodule/xmodule/vertical_block.py index c5dff07c0d..52266d0e80 100644 --- a/common/lib/xmodule/xmodule/vertical_block.py +++ b/common/lib/xmodule/xmodule/vertical_block.py @@ -66,7 +66,9 @@ class VerticalBlock(SequenceFields, XModuleFields, StudioEditableBlock, XmlParse usage_key=self.location), # pylint: disable=no-member if 'username' not in child_context: user_service = self.runtime.service(self, 'user') - child_context['username'] = user_service.get_current_user().opt_attrs['edx-platform.username'] + child_context['username'] = user_service.get_current_user().opt_attrs.get( + 'edx-platform.username' + ) child_blocks = self.get_display_items()