Closed
Conversation
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
OpenAPI ChangesShow/hide ## Changes for v0.yaml:Unexpected changes? Ensure your branch is up-to-date with |
Comment on lines
+1633
to
+1637
| transaction.on_commit( | ||
| partial( | ||
| push_edx_modes_from_run, course_run=target_course, edx_client=edx_client | ||
| ) | ||
| ) |
There was a problem hiding this comment.
Bug: The process_course_run_clone function incorrectly passes a Studio API client to push_edx_modes_from_run, which requires an LMS client to create course modes, causing enrollment setup to fail.
Severity: CRITICAL
Suggested Fix
The call to push_edx_modes_from_run should not be passed the Studio-based edx_client. Either pass edx_client=None to allow the function to default to the correct LMS service client, or explicitly pass a client created with get_edx_api_service_client().
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: openedx/api.py#L1633-L1637
Potential issue: In `openedx/api.py`, the `process_course_run_clone` function creates an
`edx_client` configured to use the Studio API (`use_studio=True`). This client is then
passed to `push_edx_modes_from_run` within a `transaction.on_commit` hook. The
`push_edx_modes_from_run` function uses this client to call `create_edx_course_mode`,
which is an LMS API endpoint, not a Studio one. This mismatch will cause the API call to
fail, likely with a 404 error. As a result, newly cloned course runs will be created
without the proper enrollment modes, breaking enrollment functionality for those
courses.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nathan Levesque
James Kachel
annagav