-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix: added content search to lms installed apps #36802
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
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. |
|
Hi @pomegranited! 👋 |
|
Hi @Asespinel :)
My apologies, but I won't have time to look at this for a few weeks. @mphilbrick211 Could you help us find a reviewer? |
|
@openedx/wg-build-test-release-security-patchers would someone be able to take a look at this? |
mariajgrimaldi
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.
@Asespinel: I don't really understand how these imports are related to the Feedback Xblock. Can you elaborate further how the using the block raises those errors? Also, I do think the safest approach would be to find the root of the problem, instead of adding try-excepts to avoid the runtime issues. Can we do that instead?
Hi majo, I hope everything is well. The problem occurs because the search model isn't registered in the INSTALLED APPS of the LMS. If we don't use those import catchins, we get a Runtime error when going into the instructor tab: The platform import get_lms_link_for_item was added to the plugin in December 2023: When the plugin imports this function, it indirectly triggers a chain of imports: cms/djangoapps/contentstore/toggles.py → And finally, it tries to import this model: SearchAccess That last import is where the error happens. The SearchAccess model was only added in April 2024: That’s why this import didn’t fail in Redwood, but it does fail in Sumac, since SearchAccess didn’t exist in Redwood. Now, after adding these changes we don't get that error and I see the course feedback tab correctly. |
cms/djangoapps/contentstore/utils.py
Outdated
| from xmodule.services import ConfigurationService, SettingsService, TeamsConfigurationService | ||
|
|
||
| from .models import ComponentLink, ContainerLink | ||
| try: |
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.
@Asespinel just curious — could you share a bit more context on why these changes to the contentstore module are needed?
| INDEX_SEARCHABLE_ATTRIBUTES, | ||
| INDEX_SORTABLE_ATTRIBUTES | ||
| ) | ||
| from openedx.core.djangoapps.content.search.models import IncrementalIndexCompleted, get_access_ids_for_request |
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.
Do we also need to move the index_config imports inside the try/except block? Or is it enough to just wrap the models imports? when are the imports from index_config getting triggered?
|
@mariajgrimaldi as @Asespinel explained in more detail, we recently discovered that the We considered two possible solutions:
Given that some imports were wrapped in a try/except when the model was originally introduced, we thought following that pattern here would be appropriate. That said, we’d love to hear what you think about the approach we're proposing — or if you believe there’s a better way to solve the issue |
|
Thank you both for the context, @magajh @Asespinel! What I'd like to understand is why adding I'll tag @rpenido and @pomegranited in case they have more insight on this issue. In the meantime, I think about this more thoroughly. Thanks! |
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.
I would rather avoid this approach. Wrapping imports in try-except increases the complexity of the entire module. It creates two realities (one where the classes are defined, and another where the classes aren't) and our unit tests will most likely cover only one of those realities, leaving the other reality untested. Same for our manual named-release tests.
Is there a reason not to add content.search to the INSTALLED_APPS?
You're absolutely right—wrapping imports in try-except can introduce unnecessary complexity and lead to inconsistent test coverage. I agree that adding content.search to INSTALLED_APPS is a cleaner and more reliable approach. If everyone is on board with this direction, I'm happy to go ahead and make that change. Let me know if there are any concerns before I proceed. |
|
@Asespinel: yes, I think that would be the cleanest approach. Thank you all :) |
d38d5df to
28b81e4
Compare
|
Done @mariajgrimaldi @kdmccormick ! Please let me know if you need some changes. |
|
Please update the PR title, commit message, and description. |
25e0a61 to
7d6dea5
Compare
|
@kdmccormick I updated the descriptiosn as requested, I also created a PR with this change for teak here: #36864. Please let me know if you require more changes. Thanks! |
|
@bradenmacdonald You originally wrote the search app and added it to CMS's installed apps list. Before we merge, is there any reason we should not install this app into LMS as well? |
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.
@kdmccormick The search app is really just designed to work in CMS at the moment. I am not sure if it will directly cause any problems by adding it to the LMS, but I think it would give the false impression that it's "meant" to be used in an LMS context, which it's really not.
There is a content search feature in the LMS but it needs a complete overhaul at some point, and when that work is done we would decide if we're expanding content.search to support LMS use cases or implementing a separate content.learner_search app. The LMS permissions model is much more complicated than the Studio one, and search works totally differently in each case so I don't want people to conflate them.
we recently discovered that the SearchAccess model — which was added in 2024 — ends up being imported indirectly by a module used in the Feedback XBlock, and, since the content.search app is not included in the LMS INSTALLED_APPS, attempting to access the feedback tab in the instructor dashboard raises an import error. This seems to be the root cause of the issue.
The Feedback XBlock should not be importing get_lms_link_for_item. It's an internal CMS API, and not part of the XBlock API at all. You can also easily replicate it's functionality without importing anything: url = f"/courses/{block.course_key}/jump_to/{block.location}". If you need an absolute URL, just copy the entire code of get_lms_link_for_item into your XBlock, or add a proper XBlock service for getting block URLs (which we should have anyways).
There are other problematic imports in FeedbackXBlock that are totally breaking separation of concerns, but maybe that's necessary for it to work at all. So my recommendation is just to re-implement get_lms_link_for_item in the block or replace it with an even simpler version as shown above.
I don't quite understand the question here but i'm happy to answer any questions about SearchAccess. It's just used to map each course/library to an integer ID which makes Studio search permissions work more efficiently. If your test case is not trying to update the studio search index (and it shouldn't be), there's no reason it should be dealing with |
Great, that sounds like the right fix.
Okay, was it known from this start that this app was only meant to be used in the CMS? The best way to indicate that would have been putting it in the |
That makes sense to me, but I've always operated based on this guidance which totally contradicts that. (And |
|
@bradenmacdonald That's fair. That README guidance is very misleading. Here's a PR to update it.
I know cms/djangoapps/contenstore is way too big, but even so, it's really nice to have CMS-specific code sequestered into the cms root directory. We even have some importlinter contracts to help (partially) enforce that. It would be cool to move that search app to cms one day. Even content_libraries probably belongs under cms (#33428) |
|
@kdmccormick |
|
Closed in favor of openedx/FeedbackXBlock#166 |

Description
This PR adds openedx.core.djangoapps.content.search to INSTALLED_APPS in lms/envs/common.py to restore the functionality of the Feedback XBlock tab in the Instructor tab.
The Feedback XBlock tab relies on the get_lms_link_for_item utility, which internally depends on openedx.core.djangoapps.content.search
Testing instructions
1.Install FeedbackXblock
2. Add the following patch as an inline plug-in in tutor.
Deadline
None