Skip to content

fix: make discovery service dependency optional for discussion notifications#37039

Open
asajjad2 wants to merge 1 commit intoopenedx:masterfrom
asajjad2:areeb/optional-discovery-dependency
Open

fix: make discovery service dependency optional for discussion notifications#37039
asajjad2 wants to merge 1 commit intoopenedx:masterfrom
asajjad2:areeb/optional-discovery-dependency

Conversation

@asajjad2
Copy link
Contributor

@asajjad2 asajjad2 commented Jul 17, 2025

What are the relevant tickets?

#6471, #6650

Description (What does it do?)

When the Discussions MFE is enabled via the discussions.enable_discussions_mfe Waffle flag, users encounter noisy error logs like:

Unable to retrieve details about Data for course_run course-v1:MITxT+21A.819.2x+3T2022 because Catalog Integration is not enabled

This error occurs in deployments where the Discovery service (Catalog Integration) is not configured, but the system still attempts to fetch course duration data for notification filtering.

The discussion notification system uses filter_audit_expired_users_with_no_role to exclude audit learners whose access has expired. This filtering logic calls:

  • get_expected_duration() to determine course duration
  • get_course_run_details() to fetch weeks_to_complete from Discovery
  • check_catalog_integration_and_get_user() which logs an error when Catalog Integration is disabled

This PR modifies get_expected_duration() in course_date_signals/utils.py to:

  1. Check if Catalog Integration is enabled before attempting to call Discovery
  2. Use the default minimum duration (4 weeks) when Discovery is unavailable
  3. Maintain existing behavior when Discovery is enabled

Additional Changes

This PR also adds configurable Django settings COURSE_DURATION_MIN_WEEKS (default: 4) and COURSE_DURATION_MAX_WEEKS (default: 18) to allow deployments to customize course duration bounds without code changes.

Current State - The course duration bounds are currently hard-coded as constants:

MIN_DURATION = timedelta(weeks=4)(4 weeks minimum)
MAX_DURATION = timedelta(weeks=18)(18 weeks maximum)

This PR makes these durations configurable through Django settings to allow deployments to customize course duration bounds without code changes:

COURSE_DURATION_MIN_WEEKS (default: 4) - replaces the hard-coded MIN_DURATION
COURSE_DURATION_MAX_WEEKS (default: 18) - replaces the hard-coded MAX_DURATION

This change enables deployments to adjust the audit access duration policy to better suit their needs without requiring code modifications.

How can this be tested?

  • Verify the fix eliminates error logs when CatalogIntegration.is_enabled() returns False
  • Confirm existing functionality works when Discovery is enabled

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jul 17, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented Jul 17, 2025

Thanks for the pull request, @asajjad2!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform.

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.

"""
Check if catalog integration is enabled
"""
catalog_integration = CatalogIntegration.current()
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have an issue with this per se, but wouldn't it be clearer to test the setting that enables catalog integration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I only found this setting related to catalog existence on which we could place a check COURSE_CATALOG_API_URL. The setting has a default value that's always present even when Discovery isn't running, so checking it alone might incorrectly return True in broken configurations.

The CatalogIntegration.is_enabled() method, on the other hand is consistent with how other catalog functions determine enablement throughout the codebase and also seems to provides proper administrative control through the database.

@asajjad2 asajjad2 changed the title fix: make Discovery service dependency optional for discussion notifications fix: make discovery service dependency optional for discussion notifications Jul 18, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Jul 28, 2025
@mphilbrick211 mphilbrick211 requested a review from pdpinch July 28, 2025 16:56
@mphilbrick211 mphilbrick211 moved this from Waiting on Author to Ready for Review in Contributions Jul 28, 2025
)
MAX_DURATION = timedelta(
weeks=getattr(settings, 'COURSE_DURATION_MAX_WEEKS', 18)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you clarify in the PR description that MIN_DURATION and MAX_DURATION are currently hard-coded to 4 weeks and 18 weeks respectively, and that this PR makes them configurable?

I feel like this is going to require some input from the product working group, but having this context will help.

Copy link
Contributor Author

@asajjad2 asajjad2 Aug 27, 2025

Choose a reason for hiding this comment

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

@pdpinch Updated in the additional changes section

@asajjad2 asajjad2 force-pushed the areeb/optional-discovery-dependency branch from bdb9af1 to d41236d Compare September 3, 2025 06:05
@mphilbrick211 mphilbrick211 added the needs reviewer assigned PR needs to be (re-)assigned a new reviewer label Sep 17, 2025
@mphilbrick211
Copy link

@pdpinch @asajjad2 hi there! Is this still in progress?

@pdpinch
Copy link
Contributor

pdpinch commented Oct 17, 2025

@asajjad2 can you resolve the conflicts and rebase?

I would still like to get a little feedback from the product WG, since this includes adding a setting -- well, actually exposing an existing setting.

@mphilbrick211
Copy link

@asajjad2 can you resolve the conflicts and rebase?

I would still like to get a little feedback from the product WG, since this includes adding a setting -- well, actually exposing an existing setting.

@asajjad2 friendly ping on this!

@mphilbrick211 mphilbrick211 removed the needs reviewer assigned PR needs to be (re-)assigned a new reviewer label Nov 13, 2025
@mphilbrick211 mphilbrick211 moved this from Ready for Review to In Eng Review in Contributions Nov 13, 2025
@mphilbrick211 mphilbrick211 added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Nov 13, 2025
@asajjad2 asajjad2 force-pushed the areeb/optional-discovery-dependency branch from d41236d to cf92d5e Compare November 28, 2025 10:35
@asajjad2
Copy link
Contributor Author

@mphilbrick211 updated.

@mphilbrick211
Copy link

@pdpinch hi there! Are you able to review this for us?

@mphilbrick211 mphilbrick211 removed the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Dec 9, 2025
Comment on lines 747 to 767
Copy link
Contributor

Choose a reason for hiding this comment

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

@asajjad2 I don't think these changes should be here. Maybe they were removed while your PR has been open?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pdpinch updated.

@asajjad2 asajjad2 force-pushed the areeb/optional-discovery-dependency branch from 69efda7 to c8e190c Compare January 6, 2026 07:54
@Anas12091101 Anas12091101 self-requested a review January 8, 2026 12:48
@asajjad2 asajjad2 force-pushed the areeb/optional-discovery-dependency branch 2 times, most recently from 242bdd2 to a2b731c Compare January 9, 2026 12:57
Copy link
Contributor

@Anas12091101 Anas12091101 left a comment

Choose a reason for hiding this comment

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

Tested locally. LGTM 👍

@asajjad2 asajjad2 force-pushed the areeb/optional-discovery-dependency branch from a6317cd to c1b33d2 Compare January 14, 2026 13:01
@pdpinch
Copy link
Contributor

pdpinch commented Jan 19, 2026

@asajjad2 can you squash your commits?

@asajjad2 asajjad2 force-pushed the areeb/optional-discovery-dependency branch 2 times, most recently from d629985 to bbcaf2f Compare January 20, 2026 12:18
…cations

test: patch CatalogIntegration.is_enabled in expiration tests to restore mock behavior

test: patch CatalogIntegration.is_enabled in setUp/tearDown

feat: make course duration limits configurable

refactor: clears ambigous name

fix: remove unsued env vars
@asajjad2 asajjad2 force-pushed the areeb/optional-discovery-dependency branch from bbcaf2f to 6b43768 Compare February 17, 2026 14:15
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: In Eng Review

Development

Successfully merging this pull request may close these issues.

5 participants

Comments