Skip to content

InvalidKeyError with LegacyLibraryContentBlock #38230

@bradenmacdonald

Description

@bradenmacdonald

I'm not sure if my devstack is in an invalid state or not, but when I access a certain course with library content in Studio, I see this error many times in the logs. It appears a v2 library key is showing up where only a V1 key is expected.

cms-1  |   File "/openedx/edx-platform/cms/djangoapps/contentstore/api/views/course_validation.py", line 392, in list
cms-1  |     blocks = get_ready_to_migrate_legacy_library_content_blocks(course_key)
cms-1  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1  |   File "/openedx/edx-platform/cms/djangoapps/contentstore/api/views/utils.py", line 153, in get_ready_to_migrate_legacy_library_content_blocks
cms-1  |     ready_to_migrate_blocks = [block for block in blocks if block.is_ready_to_migrate_to_v2]
cms-1  |                                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1  |   File "/openedx/edx-platform/xmodule/library_content_block.py", line 143, in is_ready_to_migrate_to_v2
cms-1  |     return self.is_source_lib_migrated_to_v2 and not self.is_migrated_to_v2
cms-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1  |   File "/openedx/edx-platform/xmodule/library_content_block.py", line 135, in is_source_lib_migrated_to_v2
cms-1  |     and is_forwarded(self.source_library_key)
cms-1  |                      ^^^^^^^^^^^^^^^^^^^^^^^
cms-1  |   File "/openedx/edx-platform/xmodule/library_content_block.py", line 123, in source_library_key
cms-1  |     return LibraryLocator.from_string(self.source_library_id)
cms-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1  |   File "/mnt/opaque-keys/opaque_keys/__init__.py", line 199, in from_string
cms-1  |     raise InvalidKeyError(cls, serialized) from error
cms-1  | opaque_keys.InvalidKeyError: <class 'opaque_keys.edx.locator.LibraryLocator'>: lib:OpenCraftX:ASTROPHYS
cms-1  | [27/Mar/2026 17:46:54] "GET /api/courses/v1/migrate_legacy_content_blocks/course-v1:BradenX+TS100+23/ HTTP/1.1" 500 331112

Example OLX from the course export:

<library_content copied_from_block="block-v1:BradenX+TS100+23+type@library_content+block@1f74a1beb98a46f7a7a7a2d5087f2213" display_name="Randomized Content Block 2 (Pasted)" source_library_id="lib:OpenCraftX:ASTROPHYS" source_library_version="4">
  <html url_name="library_co-522bc4b3c0"/>
  <problem url_name="library_co-0d39c13f5c"/>
  <video url_name="library_co-2a1896dc03"/>
</library_content>

The error appears in the logs when I visit the outline page and appears in the Studio UI when I visit the unit:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions