From 497ffae5a75af1344d8e4dfb96a57996a5018c23 Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Wed, 28 Jan 2026 14:50:37 -0500 Subject: [PATCH] docs: Add learnings about `_services.copy()` fix to preview.py (#37956) Capturing what we learned in https://github.com/openedx/openedx-platform/pull/37900#issuecomment-3811194293 --- cms/djangoapps/contentstore/views/preview.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index 05fc1705e8..b83158e35c 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -200,6 +200,17 @@ def _prepare_runtime_for_preview(request, block): # See the docstring of `DjangoXBlockUserService`. deprecated_anonymous_user_id = anonymous_id_for_user(request.user, None) + # NOTE: As of Ulmo, these services only apply to the preview views. If you want a service to be present in all + # Studio ModuleStoreRuntimes, then add it to load_services_for_studio. + # HISTORICAL CONTEXT: Until Ulmo, the `block.runtime._services.update(service)` call below would + # actually update the services dictionary for all runtimes, as `_services` was aliased between them. + # This caused a grading bug, under certain conditions, so it was fixed + # in https://github.com/openedx/openedx-platform/pull/37825; now, every runtime gets a fresh, + # independent copy of `_services`. That's good, except that some Studio code had become dependent + # on the bugged behavior and thus expected the "preview" services below to be present in all Studio runtimes. + # We fixed the known instance of that bugged assumption here: + # https://github.com/openedx/openedx-platform/pull/37900. + # This comment is left here as a note for future devs investigating similar bugs. services = { "studio_user_permissions": StudioPermissionsService(request.user), "i18n": XBlockI18nService,