Skip to content

Conversation

@Asespinel
Copy link

@Asespinel Asespinel commented Jun 9, 2025

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

Prevents LMS from crashing due to unavailable CMS-only Django apps.

Makes the Feedback XBlock more robust, self-contained, and platform-agnostic.

Enables safe use of the XBlock across different Open edX deployments and service boundaries.

How to test

  1. Install the xblock using this branch
  2. Install the component in studio adding "feedback" to the advanced settings in studio
  3. Go to your course as an admin and go to the Instructor tab
  4. You should see no errors and the xblock rendering correctly
    image

@openedx-webhooks
Copy link

Thanks for the pull request, @Asespinel!

This repository is currently maintained by @openedx/axim-engineering.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jun 9, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Jun 9, 2025
@codecov
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.75%. Comparing base (a7db6e1) to head (794d752).
⚠️ Report is 47 commits behind head on master.

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     
Flag Coverage Δ
unittests 93.75% <100.00%> (+0.98%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Asespinel
Copy link
Author

@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 kdmccormick self-requested a review June 10, 2025 15:38
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Jun 12, 2025
@mphilbrick211
Copy link

@kdmccormick are you still able to review this?

@kdmccormick
Copy link
Member

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.

@mphilbrick211
Copy link

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 :)

Copy link
Member

@kdmccormick kdmccormick left a 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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# feedbackblock/feedback/utils.py

comment is not necessary

Comment on lines +4 to +6
from urllib.parse import urlencode, urlparse, urlunparse
from opaque_keys.edx.keys import UsageKey
from django.conf import settings
Copy link
Member

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

Suggested change
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

Comment on lines +1 to +5
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
Copy link
Member

Choose a reason for hiding this comment

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

import style

Suggested change
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
Copy link
Member

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.

@mphilbrick211 mphilbrick211 moved this from Ready for Review to In Eng Review in Contributions Nov 4, 2025
@kdmccormick kdmccormick moved this from In Eng Review to Waiting on Author in Contributions Nov 10, 2025
@mphilbrick211
Copy link

@kdmccormick can this be merged?

@mphilbrick211 mphilbrick211 moved this from Waiting on Author to Ready to Merge in Contributions Dec 19, 2025
@feanil
Copy link
Contributor

feanil commented Dec 22, 2025

Looks like we're waiting for a version bump on this PR so that we can release this after it's merged.

@kdmccormick
Copy link
Member

We're also waiting for the review feedback to be addressed. @Asespinel , anything we can do to help unblock this?

@mphilbrick211
Copy link

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

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

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Ready to Merge

Development

Successfully merging this pull request may close these issues.

5 participants