Bug: course index returns 500 when the user's clipboard holds content from an uninstalled XBlock
Description:
If the user's clipboard holds content from an uninstalled XBlock, GET /api/contentstore/v1/course_index/<course_key> returns a 500 for
every course a given user can see, with:
xblock.plugin.PluginMissingError: <block_type>
cms/djangoapps/contentstore/utils.py # initial_user_clipboard
openedx/core/djangoapps/content_staging/serializers.py # get_block_type_display
cms/djangoapps/contentstore/helpers.py # XBlock.load_class(category)StagedContentSerializer.get_block_type_display calls cms.djangoapps.contentstore.helpers.xblock_type_display_name, which calls
XBlock.load_class unconditionally, so it raises PluginMissingError when the plugin for the block type is not installed.
This is reachable in normal operation: the clipboard stores a copy of a block (with its OLX), and the plugin providing that block type can be removed from the platform afterwards. The clipboard is then permanently unreadable, and because initial_user_clipboard is part of the course index payload, the user cannot open any course in Studio.
/api/content-staging/v1/clipboard/ fails the same way, and it only exposes GET and POST, so the author has no way to discard the stale
clipboard either.
Steps to reproduce:
- Install a third-party XBlock, e.g.
cover(any block type not shipped with the platform works). - Copy a block of that type in Studio (select the block -> Copy).
- Remove the plugin from the platform and restart the LMS/CMS.
- As the user that copied it, open any course in Studio.
Expected behavior:
Studio opens the course, and the clipboard shows the copied content with its raw block type as the name (as already happens for v2 libraries, see openedx.core.djangoapps.xblock.api.xblock_type_display_name, which catches PluginMissingError and returns the block type).
Actual behavior:
500 from the course index API; Studio shows a server error. The same exception breaks /api/content-staging/v1/clipboard/.
Additional information:
- Fix proposed in #39152: catch
PluginMissingErrorinStagedContentSerializer.get_block_type_displayand fall back toobj.block_type, plus a regression test.
Source: openedx/openedx-platform