From d3ef43047eac68612021a1a6b8cbc38e61d44166 Mon Sep 17 00:00:00 2001 From: Kyle McCormick <kmccormick@edx.org> Date: Thu, 3 Dec 2020 09:49:27 -0500 Subject: [PATCH] Fix KeyError in v2 Libraries API (#25753) --- openedx/core/djangoapps/content_libraries/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openedx/core/djangoapps/content_libraries/views.py b/openedx/core/djangoapps/content_libraries/views.py index d1ff9a237db..bf94dc2dd18 100644 --- a/openedx/core/djangoapps/content_libraries/views.py +++ b/openedx/core/djangoapps/content_libraries/views.py @@ -158,10 +158,11 @@ class LibraryRootView(APIView): # definitions elsewhere. data['library_type'] = data.pop('type') data['library_license'] = data.pop('license') + key_data = data.pop("key") # Move "slug" out of the "key.slug" pseudo-field that the serializer added: - data["slug"] = data.pop("key")["slug"] + data["slug"] = key_data["slug"] # Get the organization short_name out of the "key.org" pseudo-field that the serializer added: - org_name = data["key"]["org"] + org_name = key_data["org"] try: ensure_organization(org_name) except InvalidOrganizationException: -- GitLab