-
Notifications
You must be signed in to change notification settings - Fork 14
fix: fixed the lms link imports to avoid a runtime error #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Thanks for the pull request, @Asespinel! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #166 +/- ##
==========================================
+ Coverage 92.76% 93.75% +0.98%
==========================================
Files 5 5
Lines 221 240 +19
==========================================
+ Hits 205 225 +20
+ Misses 16 15 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@kdmccormick @openedx/axim-engineering this PR solves the issue discussed in openedx/openedx-platform#36802 please let me know if you need something else |
|
@kdmccormick are you still able to review this? |
|
Yep, but I will not be able to get to it until next week. If there are any edx-platform CCs that are available to take a look in the meantime they're welcome to review instead. |
Bumping this @kdmccormick :) |
kdmccormick
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for the fix! Can you bump the patch version so that this can be released? Then I'll be happy to approve and merge.
| @@ -1,6 +1,44 @@ | |||
| """Utilities for feedback app""" | |||
|
|
|||
| # feedbackblock/feedback/utils.py | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # feedbackblock/feedback/utils.py |
comment is not necessary
| from urllib.parse import urlencode, urlparse, urlunparse | ||
| from opaque_keys.edx.keys import UsageKey | ||
| from django.conf import settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please follow the style guide for imports
| from urllib.parse import urlencode, urlparse, urlunparse | |
| from opaque_keys.edx.keys import UsageKey | |
| from django.conf import settings | |
| from urllib.parse import urlencode, urlparse, urlunparse | |
| from django.conf import settings | |
| from opaque_keys.edx.keys import UsageKey |
| from feedback.utils import get_lms_link_for_item | ||
| from opaque_keys.edx.keys import UsageKey | ||
| from unittest.mock import Mock | ||
| import sys | ||
| import types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import style
| from feedback.utils import get_lms_link_for_item | |
| from opaque_keys.edx.keys import UsageKey | |
| from unittest.mock import Mock | |
| import sys | |
| import types | |
| import sys | |
| import types | |
| from unittest.mock import Mock | |
| from opaque_keys.edx.keys import UsageKey | |
| from feedback.utils import get_lms_link_for_item |
|
|
||
| try: | ||
| # pylint: disable=import-outside-toplevel | ||
| from openedx.core.djangoapps.site_configuration.models import SiteConfiguration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally speaking, it is a bad pattern for plugins to import code from edx-platform, as it creates coupling between something that is supposed to be stable (the plugin) and something that is inherently unstable (edx-platform modules). However, I don't know of any better way to let this block access SiteConfiguration other than adding an new XBlock runtime service, and I don't think a new SiteConfig runtime service is a good idea either given that we want to move away from SiteConfig. So, long story short, this is a bad pattern, but I'm OK with it for this PR given that there's no better way and we need a quick fix for this bug.
|
@kdmccormick can this be merged? |
|
Looks like we're waiting for a version bump on this PR so that we can release this after it's merged. |
|
We're also waiting for the review feedback to be addressed. @Asespinel , anything we can do to help unblock this? |
Friendly ping on this, @Asespinel |
Description
This PR resolves a critical issue where the LMS crashes when the Feedback XBlock is loaded. The problem stems from the XBlock importing a utility function from the openedx.core.djangoapps.content.search.models module, which is only available in the CMS (Studio) context. More information here: #164
Because the content.search app is not installed or initialized in the LMS, attempting to import from it causes runtime errors, resulting in LMS failures when rendering or initializing the XBlock.
Solution
To fix this, the offending import has been fully removed, and the required functionality has been re-implemented locally within the utils.py file of the Feedback XBlock. This decouples the XBlock from platform-specific CMS-only dependencies, ensuring it works in both LMS and Studio environments.
This solution avoids runtime exceptions and ensures the XBlock operates independently of internal platform modules not shared across services.
🔍 Why this matters
How to test