From ea6b5b9e3c5f51690858b3d8ce0106c76a0ccbf6 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Fri, 22 Apr 2022 09:08:03 -0400 Subject: [PATCH] fix: guard access to course block children in outline tab data In some cases the course blocks API was returning a dict without a 'children' key, which was causing a traceback. If the course blocks API has no children, that's IS a problem, but still better than erroring out due to a KeyError. AA-1267 --- lms/djangoapps/course_home_api/outline/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/djangoapps/course_home_api/outline/views.py b/lms/djangoapps/course_home_api/outline/views.py index c9c88c52ca..6f059ee598 100644 --- a/lms/djangoapps/course_home_api/outline/views.py +++ b/lms/djangoapps/course_home_api/outline/views.py @@ -289,7 +289,7 @@ class OutlineTabView(RetrieveAPIView): # course_blocks is a reference to the root of the course, so we go # through the chapters (sections) to look for sequences to remove. - for chapter_data in course_blocks['children']: + for chapter_data in course_blocks.get('children', []): chapter_data['children'] = [ seq_data for seq_data in chapter_data['children']