Skip to content

fix: Studio v3 home: no write on GET, no-op org, public schema - #39310

Open
Faraz32123 wants to merge 7 commits into
masterfrom
fix/studio-home-creator-status-read-only
Open

Faraz32123 wants to merge 7 commits into
masterfrom
fix/studio-home-creator-status-read-only

Conversation

@Faraz32123

@Faraz32123 Faraz32123 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the v3 home issues raised on #39263, so it can serve as the public replacement for GET /api/contentstore/v1/home.

  • No write on GET. With ENABLE_CREATOR_GROUP on, loading Studio home (v1, v3 and the legacy page) inserted an unrequested CourseCreator row for non-staff users. The status is now reported as unrequested without a write, and request_course_creator creates the row when the user asks for access. It's created as unrequested and then saved as pending, so the admin notification still fires.
  • org removed from the v3 home list schema. That action never loads courses, so the parameter did nothing.
  • v3 home is no longer x-internal. v1 home is public and v3 is its replacement. ADR 0038 allows x-internal only for the unversioned course_home BFF, and lists Studio home among the screen names to replace. This removes it from both mounts. The legacy /api/contentstore/v3/home/ was public before feat: apply ADR 0038 (URL structure standardization) across 6 standardized APIs #39078 and stays deprecated.

Course creator requests and the admin. request_course_creator does nothing for staff, with the creator group off, or with course creation disabled, since the table isn't read there. Staff can now add CourseCreator rows in the admin (user picked by id on the add form, read-only after), so admins can still grant access to someone who hasn't requested it.

Testing: course creators, v1/v3 home, spectacular, library and course-creation tests pass locally. New tests fail without the fix. The generated CMS schema has no x-internal operations, and /api/authoring/v3/home/ keeps its SDK tag. docs/cms-openapi.yaml is left to the schema workflow.

Note: #39300 removes the hook block from cms/envs/devstack.py and production.py; whichever lands second drops the comment edit there.

Related: #39263, #39068

🤖 Generated with Claude Code

user = CourseCreator.objects.get(user=user)
# Created as 'unrequested' and then saved as 'pending', so that the change
# of state notifies the admins.
user, _ = CourseCreator.objects.get_or_create(user=user)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_or_create turns a request that used to fail into one that writes. Before this change, a user with no row hit DoesNotExist here (a 500, nothing written). The only users without rows were global staff, and everyone on a site with ENABLE_CREATOR_GROUP off or DISABLE_COURSE_CREATION on.

Now any logged-in user who POSTs to /request_course_creator gets a pending row, and the admins get an email. That includes:

  • global staff, whom _add_user deliberately never adds;
  • sites with the creator group off;
  • sites with course creation disabled, where the request can never be granted.

Could this be a no-op in the cases where _get_course_creator_status never reads the table? Something like:

if (
    user.is_staff
    or getattr(settings, 'DISABLE_COURSE_CREATION', False)
    or not getattr(settings, 'ENABLE_CREATOR_GROUP', False)
):
    return

Please also add a test for each of the three cases. test_user_requested_access_without_an_entry would then need @override_settings(ENABLE_CREATOR_GROUP=True) instead of relying on the default.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done. user_requested_access is now a no-op for staff, with the creator group off, and with course creation disabled, the cases where _get_course_creator_status never reads the table. Added a test for each, and test_user_requested_access_without_an_entry (and the old test_user_requested_access) now set ENABLE_CREATOR_GROUP=True explicitly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against 6f8c8a2: fixed as described. Resolving.

# Add the user to the course creator admin table with status 'unrequested'.
add_user_with_status_unrequested(user)
course_creator_status = get_course_creator_status(user)
course_creator_status = get_course_creator_status(user) or CourseCreator.UNREQUESTED

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the side effect in the description: I think this needs a decision before merge rather than a note. CourseCreatorAdmin returns False from has_add_permission and keeps username read-only, so an admin can no longer grant creator access to someone who hasn't requested it. Operators who pre-approve staff or instructors today lose that workflow.

Two options I can see:

  • allow adding rows in the admin, with user editable only on the add form;
  • keep the behaviour and add an operator-facing release note saying users appear in the admin only after they request access.

I'd lean towards the first, since it keeps the old capability without bringing back the write on GET.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, went with the first option. Staff can add rows in the admin now; user is picked by id on the add form and stays read-only on the change form. Added a test that adds a user who never requested access as granted through the admin and checks they land in the creator group. I've dropped the side-effect note from the description.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The add form covers the capability, thanks. It's still something operators will notice though: with ENABLE_CREATOR_GROUP on by default, the Course Creator admin stops listing every user who has opened Studio, and granting access ahead of a request now goes through the add form. Can you add an entry for that to the Willow operator notes before this merges? https://openedx.atlassian.net/wiki/spaces/COMM/pages/6476169217/Willow+-+Operator+Dev+Notes

Something like:

Course creator access: Studio users no longer appear in the Course Creator admin as unrequested just by visiting Studio; a user is added only when they request course creator access. To grant access to someone before they request it, use the new "Add course creator" button in the Course Creator admin.

@taimoor-ahmed-1 taimoor-ahmed-1 Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction to my note above: the code side (the add form, user read-only on the change form, and the test) is in 6f8c8a2, but the Willow operator-notes entry asked for here is not on the page yet as of Nov 11. This stays open until that entry is added.

Comment thread cms/envs/devstack.py Outdated
@@ -356,9 +356,9 @@ def should_show_debug_toolbar(request): # pylint: disable=missing-function-docs
'SERVE_INCLUDE_SCHEMA': False,
# restrict spectacular to CMS API endpoints (cms/lib/spectacular.py):
'PREPROCESSING_HOOKS': ['cms.lib.spectacular.cms_api_filter'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a rebase, it conflicts with master in cms/envs/devstack.py and cms/envs/production.py after #39300 removed the SPECTACULAR_SETTINGS hook block from both. Taking master's version of both files resolves it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased onto master and took master's version of devstack.py and production.py.

assert get_course_creator_status(self.user) is None
admin_notification.send.assert_not_called()

def test_user_requested_already_granted(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_user_requested_already_granted(self):
@override_settings(ENABLE_CREATOR_GROUP=True)
def test_user_requested_already_granted(self):

The test settings have ENABLE_CREATOR_GROUP = False, so user_requested_access now returns before it reaches the "already granted" branch and this test no longer exercises it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -89,7 +89,6 @@ def get_serializer(self, *args, **kwargs):
@extend_schema(
responses={(200, "application/json"): StudioHomeSerializer},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With get_home_context(request, True), courses, archived_courses, in_process_course_actions and libraries are always empty (contentstore/utils.py:1687-1698), but StudioHomeSerializer still describes them, and this PR makes that schema public. If the data is not going to be there, the contract shouldn't make it seem like it will be. Give v3 its own serializer without those four keys (v1 can keep StudioHomeSerializer), and update the list docstring, which still says it returns all courses and libraries and gives ?fields=courses,libraries as an example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. v3 now has its own StudioHomeContextSerializer without those four keys (v1 keeps StudioHomeSerializer), and the list docstring and ?fields= example are updated.

Comment thread cms/lib/spectacular.py

# BFF surfaces, marked x-internal so clients can tell them from a stable
# resource contract. Both the legacy and conforming mounts.
INTERNAL_BFF_PATH_PREFIXES = (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this also publishes the courses and libraries actions of HomeViewSet on both mounts, and neither should be part of the public contract. courses is replaced by /api/authoring/v4/courses/, and libraries is the legacy library list, which goes away under #37931. Add @extend_schema(exclude=True) to both actions so only list is published. Since the viewset backs both mounts, that covers /api/contentstore/v3/home/ as well.

For courses, can you also open a DEPR to remove it once the MFEs are using /api/authoring/v4/courses/? libraries doesn't need one, #37931 covers it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, both actions are @extend_schema(exclude=True) now, with a test that neither is published on either mount. I'll open the DEPR for removing courses and link it here.

return
# Created as 'unrequested' and then saved as 'pending', so that the change
# of state notifies the admins.
user, _ = CourseCreator.objects.get_or_create(user=user)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: After this change add_user_with_status_unrequested only has callers in tests, so it can go.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, along with the tests that only covered it.

# Add the user to the course creator admin table with status 'unrequested'.
add_user_with_status_unrequested(user)
course_creator_status = get_course_creator_status(user)
course_creator_status = get_course_creator_status(user) or CourseCreator.UNREQUESTED

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The add form covers the capability, thanks. It's still something operators will notice though: with ENABLE_CREATOR_GROUP on by default, the Course Creator admin stops listing every user who has opened Studio, and granting access ahead of a request now goes through the add form. Can you add an entry for that to the Willow operator notes before this merges? https://openedx.atlassian.net/wiki/spaces/COMM/pages/6476169217/Willow+-+Operator+Dev+Notes

Something like:

Course creator access: Studio users no longer appear in the Course Creator admin as unrequested just by visiting Studio; a user is added only when they request course creator access. To grant access to someone before they request it, use the new "Add course creator" button in the Course Creator admin.

Faraz32123 and others added 7 commits November 10, 2026 15:17
With ENABLE_CREATOR_GROUP on, reading the home page inserted an
'unrequested' CourseCreator row for a non-staff user without one. The
status is now reported as 'unrequested' without a write, and the row is
created when the user requests access.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The list action never loads courses, so org had no effect.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
v1 home is public, and v3 home is its replacement. ADR 0038 allows
x-internal only for the unversioned course_home BFF, and lists Studio
home among the screen names to replace, not to mark internal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Staff, sites with the creator group off, and sites with course creation
disabled never read the CourseCreator table, so a request there no
longer creates a pending row or emails the admins.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rows are no longer created when a user opens Studio home, so admins
need a way to grant access to someone who has not requested it. The
user is picked by id on the add form and stays read-only afterwards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The v3 home builds its context without courses, so the courses,
archived_courses, in_process_course_actions and libraries keys are
always empty. Describe the response without them, and keep the
courses and libraries actions out of the public schema: courses is
replaced by /api/authoring/v4/courses/, and the legacy library list
is being removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Studio home no longer adds unrequested entries, so the helper has no
callers outside tests. The already-granted test now enables the creator
group, since user_requested_access returns early without it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants