diff --git a/openedx_learning/apps/authoring/components/api.py b/openedx_learning/apps/authoring/components/api.py index a65eee80..1355a2ff 100644 --- a/openedx_learning/apps/authoring/components/api.py +++ b/openedx_learning/apps/authoring/components/api.py @@ -269,7 +269,15 @@ def get_component_by_uuid(uuid: UUID) -> Component: def get_component_version_by_uuid(uuid: UUID) -> ComponentVersion: - return ComponentVersion.objects.get(publishable_entity_version__uuid=uuid) + return ( + ComponentVersion + .objects + .select_related( + "component", + "component__learning_package", + ) + .get(publishable_entity_version__uuid=uuid) + ) def component_exists_by_key( @@ -510,7 +518,12 @@ def _error_header(error: AssetError) -> dict[str, str]: # Check: Does the ComponentVersion exist? try: - component_version = get_component_version_by_uuid(component_version_uuid) + component_version = ( + ComponentVersion + .objects + .select_related("component", "component__learning_package") + .get(publishable_entity_version__uuid=component_version_uuid) + ) except ComponentVersion.DoesNotExist: # No need to add headers here, because no ComponentVersion was found. logger.error(f"Asset Not Found: No ComponentVersion with UUID {component_version_uuid}")